Skip to content
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

Ensure headers passed to Hackney as case-insensitive? #100

Closed
tjsousa opened this issue Nov 23, 2015 · 11 comments
Closed

Ensure headers passed to Hackney as case-insensitive? #100

tjsousa opened this issue Nov 23, 2015 · 11 comments

Comments

@tjsousa
Copy link

tjsousa commented Nov 23, 2015

I've run into an issue where I'm passing headers (including a host header) coming from a Plug's connection into HTTPoison, which default to lower-case, thus causing :hackney to override the Host header (because it matches a capitalized one).

The referred use-case is for an app acting as a reverse-proxy where transparently passing headers, specially the Host header is very important.

A workaround have been suggested, which I feel would be best implemented at the httpoison lib level to avoid this issue for other users as well.

What do you guys think?

@edgurgel
Copy link
Owner

Hm.. I would open an issue to fix hackney so it looks for Host without a specific case, which seems to be the perfect solution. Would it fix the problem?

cc/ @benoitc

@tjsousa
Copy link
Author

tjsousa commented Nov 25, 2015

Yup, indeed. It seems like this existing issue could make it possible:
benoitc/hackney#114

Thanks @edgurgel !

@gosseti
Copy link

gosseti commented Feb 15, 2017

@tjsousa Just stumbled across this issue. I’m getting the error:

[error] proxy error: "HTTP/1.1 400 Bad Request\r\nContent-Type: text/plain\r\nConnection: close\r\n\r\n400 Bad Request: missing required Host header"

It’s related to the same one you’ve experienced above. Is there some way to explicitly pass the Host header to HTTPoison so that it doesn’t get overwritten/downcased by hackney? How did you solve this in the end?

I also put a StackOverflow question up here for it: http://stackoverflow.com/questions/42210304/elixir-httpoison-no-case-clause-matching-false-error

@suprafly
Copy link

Still seeing this issue.

@tcitworld
Copy link

Has there been any developments here ?

@benoitc
Copy link

benoitc commented May 12, 2018

@tcitworld it has been fixed in hackney. Do you still reproduce the issue?

@tcitworld
Copy link

You mean by using the hackney_headers module instead ?

@facundoolano
Copy link

Still seeing this issue (case sensitive headers) in HTTPoison. And, to be honest, having to resort to hackney_headers kind of defeats the purpose of using an Elixir wrapper library.

@benoitc
Copy link

benoitc commented Jun 14, 2018

Host header is passed once.

@facundoolano do you have any example?

@facundoolano
Copy link

facundoolano commented Jun 14, 2018

@benoitc I guess my issue is more related to the title than the description. My main problem is that there's no case insensitive way to access response headers, so I need to know how the server sends them to fetch them, or manually downcase all the keys first.

@edgurgel
Copy link
Owner

edgurgel commented Oct 1, 2021

Closing due to inactivity. Happy to accept a PR to get a header from HTTPoison's module

@edgurgel edgurgel closed this as completed Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants