diff --git wp-includes/rest-api.php wp-includes/rest-api.php
index 3b158ea07f..32ecb723dc 100644
|
|
function rest_api_loaded() { |
269 | 269 | $route = '/'; |
270 | 270 | } |
271 | 271 | $server->serve_request( $route ); |
| 272 | $server->finish_request(); |
272 | 273 | |
273 | 274 | // We're done. |
274 | 275 | die(); |
diff --git wp-includes/rest-api/class-wp-rest-server.php wp-includes/rest-api/class-wp-rest-server.php
index c69cb4834c..a7da5393fb 100644
|
|
class WP_REST_Server { |
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
| 417 | * Handles finishing an API request. |
| 418 | * |
| 419 | * Closes connections, where possible, so the response is sent as soon as possible |
| 420 | * and is not slowed down by functions during shutdown. |
| 421 | * |
| 422 | * @access public |
| 423 | */ |
| 424 | public function finish_request() { |
| 425 | if ( is_callable( 'fastcgi_finish_request' ) ) { |
| 426 | // This function is available on nginx and is the cleanest solution. |
| 427 | fastcgi_finish_request(); |
| 428 | |
| 429 | } elseif ( ! headers_sent() ) { |
| 430 | // For apache, we can send some headers to end the connection early. |
| 431 | header( 'Content-Length: ' . ob_get_length() ); |
| 432 | header( 'Connection: close' ); |
| 433 | ob_end_flush(); |
| 434 | flush(); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | /** |
417 | 439 | * Converts a response to data to send. |
418 | 440 | * |
419 | 441 | * @since 4.4.0 |