WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#40347 closed defect (bug) (fixed)

WP_REST_Request::remove_header() does not canonicalize header name

Reported by: TimothyBlynJacobs Owned by: joehoyle
Milestone: 4.8 Priority: normal
Severity: normal Version: 4.4
Component: REST API Keywords: has-patch has-unit-tests
Focuses: rest-api Cc:

Description

$request->add_header( 'Content-Type', 'application/json' );
$request->remove_header( 'Content-Type' );
$request->get_header( 'Content-Type' ); // still outputs 'application/json'

Patch incoming.

Attachments (1)

40347.diff (1.3 KB) - added by TimothyBlynJacobs 3 years ago.

Download all attachments as: .zip

Change History (4)

#1 @TimothyBlynJacobs
3 years ago

  • Keywords has-patch has-unit-tests added

#2 @swissspidy
3 years ago

  • Milestone changed from Awaiting Review to 4.8

#3 @joehoyle
3 years ago

  • Owner set to joehoyle
  • Resolution set to fixed
  • Status changed from new to closed

In 40577:

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.

Note: See TracTickets for help on using tickets.