-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why do headers convert into lowercase automatically? #71
Comments
The HTTP spec defines header names as case insensitive. Fastify, and
|
Fair point but I ask this from an aesthetic point of view. Headers from helmet (https://github.com/fastify/fastify-helmet) are all capitalized and look much better. Any way to achieve the same?
|
Fastify handles headers this way as a performance optimization. By only handling headers in a lowercased format, Fastify has better performance and uses less memory. Also, the Internet will eventually move to HTTP/2, which only supports lowercase headers, so it's not worth getting attached to the aesthetic look of HTTP/1-style headers. |
“Life can only be understood backwards; but it must be lived forwards.” |
No workaround? |
That is an incorrect statement. https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2 |
@StingyJack Semantics ¯\_(ツ)_/¯ While uppercase headers can be used at the application level, they will always be sent as lowercase.
|
Reverting header case as fastify will convert headers to lowercase fastify/help#71
Fair point, but it would be better to mention it here https://fastify.dev/docs/latest/Reference/Request/#headers. |
Feel invited to provide a PR to improve the documentation. ;) |
What are you trying to achieve or the steps to reproduce?
I would like to know how to capitalize headers when sending the response. Looks like Fastify converts the headers to lowercase while sending the response.
What was the result you received?
What did you expect?
Context
The text was updated successfully, but these errors were encountered: