diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
index d4c0aca..3a5fc1a 100644
|
a
|
b
|
function rest_handle_options_request( $response, $handler, $request ) { |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | $data = $handler->get_data_for_route( $route, $endpoints, 'help' ); |
| 434 | | $accept = array_merge( $accept, $data['methods'] ); |
| | 434 | $response->set_matched_route( $route ); |
| 435 | 435 | break; |
| 436 | 436 | } |
| 437 | | $response->header( 'Accept', implode( ', ', $accept ) ); |
| 438 | 437 | |
| 439 | 438 | $response->set_data( $data ); |
| 440 | 439 | return $response; |
diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php
index 7d5cf68..3c2c930 100644
|
a
|
b
|
class Tests_REST_Server extends WP_Test_REST_TestCase { |
| 285 | 285 | $this->assertEquals( $sent_headers['Allow'], 'POST' ); |
| 286 | 286 | } |
| 287 | 287 | |
| | 288 | public function test_allow_header_sent_on_options_request() { |
| | 289 | register_rest_route( 'test-ns', '/test', array( |
| | 290 | array( |
| | 291 | 'methods' => array( 'GET' ), |
| | 292 | 'callback' => '__return_null', |
| | 293 | ), |
| | 294 | array( |
| | 295 | 'methods' => array( 'POST' ), |
| | 296 | 'callback' => '__return_null', |
| | 297 | 'permission_callback' => '__return_null', |
| | 298 | ), |
| | 299 | ) ); |
| | 300 | |
| | 301 | $request = new WP_REST_Request( 'OPTIONS', '/test-ns/test' ); |
| | 302 | $response = $this->server->dispatch( $request ); |
| | 303 | |
| | 304 | $result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $this->server, $request ); |
| | 305 | |
| | 306 | $headers = $result->get_headers(); |
| | 307 | |
| | 308 | $this->assertEquals( 'GET', $headers['Allow'] ); |
| | 309 | } |
| | 310 | |
| 288 | 311 | public function permission_denied() { |
| 289 | 312 | return new WP_Error( 'forbidden', 'You are not allowed to do this', array( 'status' => 403 ) ); |
| 290 | 313 | } |