REST API: WP_REST_Request::remove_header() should canonicalize header names.
When headers are stored in WP_REST_Request internally they are canonicalized. This step already happens on setting / getting headers in any way, but was missed when implementing remove_header(). Props TimothyBlynJacobs. Fixes #40347. git-svn-id: https://develop.svn.wordpress.org/trunk@40577 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
09fad66ae4
commit
cc661013cf
@ -286,6 +286,7 @@ class WP_REST_Request implements ArrayAccess {
|
||||
* @param string $key Header name.
|
||||
*/
|
||||
public function remove_header( $key ) {
|
||||
$key = $this->canonicalize_header_name( $key );
|
||||
unset( $this->headers[ $key ] );
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,14 @@ class Tests_REST_Request extends WP_UnitTestCase {
|
||||
$this->assertNull( $this->request->get_header_as_array( 'missing' ) );
|
||||
}
|
||||
|
||||
public function test_remove_header() {
|
||||
$this->request->add_header( 'Test-Header', 'value' );
|
||||
$this->assertEquals( 'value', $this->request->get_header( 'Test-Header' ) );
|
||||
|
||||
$this->request->remove_header( 'Test-Header' );
|
||||
$this->assertNull( $this->request->get_header( 'Test-Header' ) );
|
||||
}
|
||||
|
||||
public function test_header_multiple() {
|
||||
$value1 = 'application/x-wp-example-1';
|
||||
$value2 = 'application/x-wp-example-2';
|
||||
|
Loading…
Reference in New Issue
Block a user