According to https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2, HTTP headers are case insensitive. Thus, it should also handle 'content-type'.
Yo!
So this only matches case-sensitive for the headers you manually provide into the last argument. This is done as I most commonly saw Express developers use capitalized forms in their applications.
Once the helper reaches these two places:
... Node automatically lowercases any/all keys it received.
Yeah and I happen to be a portion of them who using everything lowercase in all kind of headers.
send(res, 200, { 'content-type': 'application/json' });
It took me quite a while to figure this out until I look at the code. Any plan to resolve this?
Hey @motss, sorry for the delay on this. This will be working for you in the next release 馃槃
I just lowercased any/all header keys that were passed into send before continuing any logic. If you get a chance to look at it that'd be awesome. Thanks!
LGTM! Really appreciate the fix.
What cat I do if I need to send response with uppercase letters ?
You should use @polka/send@next :: https://github.com/lukeed/polka/blob/next/packages/send/index.js
It still _reads_ your header values without caring about case, but it will _write_ output headers with capital casing.
You should also fix/report an issue with your HTTP client, because it's supposed to not matter
https://github.com/lukeed/polka/blob/d0c38636751be66991221f71d43a48cafecc7407/packages/send/index.js#L11
Makes header key lowercase.
I'm not talking about the content type, I have a problem with custom headers like
{ "Example-Header": "some value" }
Ah sorry, you didn't specify.
Then I wouldn't include them inside the send object.
Instead you could do res.setHeader('Example-Header', 'value'). It's a little more verbose, but IMO that's the price you should probably _have_ to pay for requiring non-standard/spec'd behavior. Again, whatever is reading your HTTP headers is supposed to be case-insensitive.
Yes, this is an option, but it would be better if send allowed you to do this without setHeader
Sorry, I'm really not inclined to support this. I don't want to lock in/promise vanity behavior that shouldn't be there in the first place. Forces Polka to continue that (almost) indefinitely when, again, _the HTTP spec says it's not supposed to matter._
袨泻, anyway thanks for reply and cool lib :)