edgurgel / httpoison

Yet Another HTTP client for Elixir powered by hackney
https://hex.pm/packages/httpoison
MIT License
2.23k stars 341 forks source link

Lowercase location header not recognized when constructing %HTTPoison.MaybeRedirect{} #453

Closed gianluca-nitti closed 2 years ago

gianluca-nitti commented 2 years ago

I've noticed that #424 introduced the struct %HTTPoison.MaybeRedirect{} which is returned when 3xx status codes are returned from the servers in response to requests with methods other that GET/HEAD/POST and the follow_redirect: true option.

This struct's redirect_url field is however properly populated only if the Location header returned by the server has an uppercase L; if it is, for example, location: http://example.com we get redirect_url: nil.

Since RFC 2616 Section 4.2 states that Field names are case-insensitive, in my understanding the keys of the proplist here should be lowercased and then the location key should be accessed.