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

Crash on 304 #126

Open
Hugo-Hache opened this issue Apr 12, 2019 · 1 comment
Open

Crash on 304 #126

Hugo-Hache opened this issue Apr 12, 2019 · 1 comment

Comments

@Hugo-Hache
Copy link

When receiving a 304, the library tries to request the URL of the Location header

https://github.com/myfreeweb/httpotion/blob/9172d089cd1d47cdd772d97db750882cc741055f/lib/httpotion.ex#L200-L202
https://github.com/myfreeweb/httpotion/blob/9172d089cd1d47cdd772d97db750882cc741055f/lib/httpotion.ex#L243-L247

As the Location header is not set on a HTTP 304, normalize_location crashes with the following stacktrace:

FunctionClauseError: no function clause matching in URI.parse/1
URI.parse/1 (elixir) arguments
--
0 | "nil"

File lib/uri.ex line 539 in URI.merge/2 (elixir)
File lib/httpotion.ex line 453 in HTTPotion.normalize_location/2 (httpotion)
File lib/httpotion.ex line 453 in HTTPotion.request/3 (httpotion)

To get some context, if needed, I'm using HTTPotion in a proxy, https://github.com/applidium/pericles/blob/master/proxy/lib/pericles_proxy/runner.ex

As a quick fix I created this fork Hugo-Hache@8cf2bec
I'll be happy to create a pull request from it if it looks ok for you.

@valpackett
Copy link
Owner

Good catch. I'm not sure how 304 got there. I think we should not crash even on a 302 with no Location, I'll add handling for that

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

2 participants