elixir-plug / plug_cowboy

Plug adapter for the Cowboy web server
Other
243 stars 48 forks source link

Lower case all header fields on send #79

Closed dominicletz closed 2 years ago

dominicletz commented 2 years ago

I just ran into this issue when switching to http/2 that suddenly some of my responses were invalid. The root cause turned out to be my code using "This-Type-Of-Capitalization" for HTTP headers and the cowboy adapter is not converting that. Thinking myself the adapter should do this I've googled a bit and found this confirming opinion piece :-) github.com/elixir-plug/plug/issues/197#issuecomment-76516098

So here is the patch, let me know if that is the right location to make this change.

josevalim commented 2 years ago

We don't do this on purpose to avoid the performance penalty. Although there is a config for plug to warn if you use mixed headers. Maybe we should enable it for Phoenix dev?

josevalim commented 2 years ago

Ah, it is enabled by default. It only does so during test. Maybe we should enable it on all cases... but that would be a separate discussion. Closing this for now, thanks @dominicletz !