• lyurk

    (@lyurk)


    Hi, Our rest api response headers changed from ‘X-WP-Total’ to all lowercase ‘x-wp-total’ sometime recently but I can’t track down why. Currently on WordPress 6.2.2 but not ready to update to 6.3.1 quite yet. All the documentation still has capitalisation so I can’t see the reason for the change. Any help would be much appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @lyurk

    I did a quick scan through the WP Codebase for 6.3.1, and all instances of the X-WP-Total response header being set are in the same case as you’d expect in the code.

    I then did a bit of searching online, and it seems that the newer HTTP/2 protocol defaults to lowercase headers (example discussions here, here, and here) so my guess would be that this is a change on your webserver. Perhaps being upgraded to the newer HTTP/2 protocol?

    This raises a valid point about the documentation, and I will raise this as an issue in the REST API docs repo, to see if we can get it updated to point this out for HTTP/2

    Hi @lyurk I did a bit of digging into this, and this was the feedback I received.

    Headers are case-insensitive in all versions of HTTP.

    HTTP clients also need to handle this per the spec; for example, Requests (which WP_Http uses) has a case-insensitive dictionary for this

    So it’s generally expected that headers will be case insensitive, and to not expect them to be sent using a specific case, even if they are set that way in the code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Rest API response headers now lowercase’ is closed to new replies.