mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
REST API: Allow explicit HEAD callbacks.
HEAD callbacks can now be registered independently, with the GET callback still used as a fallback. Fixes #34841. git-svn-id: https://develop.svn.wordpress.org/trunk@36535 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -138,6 +138,29 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugins should be able to register explicit HEAD callbacks before the
|
||||
* GET callback.
|
||||
*
|
||||
* @depends test_head_request_handled_by_get
|
||||
*/
|
||||
public function test_explicit_head_callback() {
|
||||
register_rest_route( 'head-request', '/test', array(
|
||||
array(
|
||||
'methods' => array( 'HEAD' ),
|
||||
'callback' => '__return_true',
|
||||
),
|
||||
array(
|
||||
'methods' => array( 'GET' ),
|
||||
'callback' => '__return_false',
|
||||
'permission_callback' => array( $this, 'permission_denied' ),
|
||||
),
|
||||
));
|
||||
$request = new WP_REST_Request( 'HEAD', '/head-request/test' );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass a capability which the user does not have, this should
|
||||
* result in a 403 error.
|
||||
|
||||
Reference in New Issue
Block a user