[wp-trac] [WordPress Trac] #54225: Request header key case inconsistencies

WordPress Trac noreply at wordpress.org
Tue Oct 5 22:25:47 UTC 2021


#54225: Request header key case inconsistencies
-----------------------------+-------------------------------------
 Reporter:  johnjamesjacoby  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  5.9
Component:  HTTP API         |    Version:  2.7
 Severity:  normal           |   Keywords:  2nd-opinion needs-patch
  Focuses:                   |
-----------------------------+-------------------------------------
 RFCs [https://tools.ietf.org/html/rfc7230#section-3.2 7230] and
 [https://tools.ietf.org/html/rfc7540#section-8.1.2 7540] define header
 keys as **case-insensitive**.

 WordPress is consistently inconsistent when it comes to :

 * Retrieving headers – always `lowercase`:
 {{{
 wp_remote_retrieve_header( $response, 'content-md5' )`
 }}}
 * Setting headers – almost always `Capital-Case`:
 {{{
 header( 'Content-Type: text/html; charset=utf-8' );
 }}}
 * Sitemaps code (from 5.5) uses `Title-case`:
 {{{
 header( 'Content-type: application/xml; charset=UTF-8' );
 }}}

 (Thankfully, when it comes to actually using the
 `wp_remote_retrieve_header()` function (and subsequently the Requests API
 and WP4.6) it resolves down to
 `Requests_Utility_CaseInsensitiveDictionary` so it is all working as
 defined in the specification.)

 Possible code/docs improvements here include:
 * standardizing when core uses which case
 * explicitly stating that header key parameters are case-insensitive

 Related to: #51736, #38231.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54225>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list