In my nginx config, I have the line
add_header 'X-Custom-Header' 'example' always;
When I access the page with curl -I http://<path to page> it returns the header as x-custom-header rather than X-Custom-Header as typed.
While HTTP headers are case-insensitive, and so this is still valid, I take the view that I am perfectly capable of typing a header in lowercase if that's what I want; I would rather have nginx do what it's told rather than something vaguely along the lines of what I told it to do.
Is there a way to stop it downcasing headers?
Looks like you are accessing your site using HTTP/2 protocol. This is exactly the expected behavior when request is served using HTTP/2, as RFC 7540 states:
Just as in HTTP/1.x, header field names are strings of ASCII characters that are compared in a case-insensitive fashion. However, header field names MUST be converted to lowercase prior to their encoding in HTTP/2. A request or response containing uppercase header field names MUST be treated as malformed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With