hackney icon indicating copy to clipboard operation
hackney copied to clipboard

Case sensitive header names

Open archaelus opened this issue 11 years ago • 10 comments

HTTP Header names are case insensitive, but Hackney returns a proplist of headers and the obvious way to extract a value proplists:get_value is case sensitive.

I would suggest either normalizing the case of the proplist keys before returning them, or return a hackney_headers data structure, which would encourage users to call hackney_headers:get_value(CaseInsensitiveKey, Headers, Default).

Doing this will ensure user code doesn't break if/when an HTTP intermediary changes the case of response headers (ala Amazon ELBs, Heroku's HTTP router, etc).

archaelus avatar Jul 11 '14 23:07 archaelus

hrm good idea, I will take care about it in next version.

benoitc avatar Sep 22 '14 11:09 benoitc

+1

ypaq avatar Dec 22 '14 12:12 ypaq

+1

tnt-dev avatar Dec 25 '14 14:12 tnt-dev

+1

jurriaan avatar Mar 08 '15 09:03 jurriaan

+1

tjsousa avatar Nov 22 '15 11:11 tjsousa

I ran into an issue when using HTTPoison, a popular Elixir client that uses Hackney, and headers from a Plug connection, which are lower-cased by default.

More info here: https://github.com/slogsdon/elixir-reverse-proxy/issues/2

tjsousa avatar Nov 22 '15 11:11 tjsousa

i will handle that i the next release. for now you can do hackney_headers:new(Headers) to use the module hackney_headers and get and an header case insensitively.

benoitc avatar Nov 23 '15 12:11 benoitc

Still seeing this issue.

suprafly avatar May 12 '17 20:05 suprafly

@suprafly next major release may have it though why not using the hackney_headers module?

benoitc avatar May 19 '17 16:05 benoitc

@benoitc Thanks. I found a work around, I messed around with using the hackney_headers module, however my problem with is that I am using hackney via the HTTPoison library in Elixir. It was not obvious how I could pass headers generated with that module down into hackney.

suprafly avatar May 19 '17 17:05 suprafly