WordPress.org

Make WordPress Core

Changeset 40577


Ignore:
Timestamp:
05/07/2017 04:08:42 AM (2 years ago)
Author:
joehoyle
Message:

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.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/class-wp-rest-request.php

    r40105 r40577  
    287287     */
    288288    public function remove_header( $key ) {
     289        $key = $this->canonicalize_header_name( $key );
    289290        unset( $this->headers[ $key ] );
    290291    }
  • trunk/tests/phpunit/tests/rest-api/rest-request.php

    r40105 r40577  
    3030        $this->assertNull( $this->request->get_header( 'missing' ) );
    3131        $this->assertNull( $this->request->get_header_as_array( 'missing' ) );
     32    }
     33   
     34    public function test_remove_header() {
     35        $this->request->add_header( 'Test-Header', 'value' );
     36        $this->assertEquals( 'value', $this->request->get_header( 'Test-Header' ) );
     37       
     38        $this->request->remove_header( 'Test-Header' );
     39        $this->assertNull( $this->request->get_header( 'Test-Header' ) );
    3240    }
    3341
Note: See TracChangeset for help on using the changeset viewer.