ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
891 stars 232 forks source link

Header field normalization should be optional #240

Closed galdor closed 3 years ago

galdor commented 3 years ago

In the current version, Gun will normalize all header fields provided by the user, transforming them to lowercase. While this is standard compliant, it makes it impossible to implement various request signature mechanisms which relies on precise header values.

An example would be the AWS signature version 4, where the user computes a hash based on header fields among other things. The user generates a hash from the header field it provides, and the result as a new header field. But Gun modifies these fields, making the hash incorrect.

A simple solution would be an option to indicate that Gun should not modify any header field provided by the user.

essen commented 3 years ago

There's the transform_header_name option here: https://ninenines.eu/docs/en/gun/2.0/manual/gun/#_http_opts

Note that HTTP/2 onward requires them to be lowercase.

galdor commented 3 years ago

That should do the trick, thank you.