-
Notifications
You must be signed in to change notification settings - Fork 530
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
Header casing #188
Comments
This has performance implications and HTTP header handling should be case insensitive. I'm unsure. |
Should this be an option? |
I agree that this might cause some performance slowdown, but if we don't lowercase all headers by default (in the response), then all of our users will need to log the headers before writing their code because they can't know in advance the casing of the headers. |
In fact, I've noticed this behavior because I was trying to port the current test in the Elasticsearch client to use |
So an option which is enabled by default? |
An option enabled by default could work, but I don't think anyone will ever change this, because it might save you a few milliseconds (did we measure how many?), but it adds a lot of complexity afterward, as you don't really know the casing of the headers. |
In Fastify we are lowercasing everything by default, and I don't think it causes a degradation in performances that justifies the complexity of supporting different solutions: https://github.com/fastify/fastify/blob/8b8485ac5ff56d1ead387f6dd76384f996a2cf8e/lib/reply.js#L162-L210 |
I did some benchmarks: With
Without
The server code: const { createServer } = require('http')
createServer((req, res) => {
res.writeHead(200, {
'content-type': 'text/plain',
'X-Foo': 'Bar'
})
res.end('hello world')
}).listen(3000) I don't see a sensible difference :) |
The headers can be either Uppercased o lowercased, based on how they have been written. I think we should lowercase every key by default, to avoid confusion.
The text was updated successfully, but these errors were encountered: