benoitc / hackney

simple HTTP client in Erlang
Other
1.34k stars 427 forks source link

Incorrect Host header used on redirected requests #693

Open sykesm opened 2 years ago

sykesm commented 2 years ago

When a request is made to a server running on a non-standard port, the port should be included in the Host header. This is part of RFC-2616.

When follow_redirect is enabled and the client gets a 302 redirect, hackney's request to the new target includes a Host header for the new host but it does not include the port. When used with strict servers, this results in a bad request response.

benoitc commented 2 years ago

mmm are you sure of this? The rfc says

A "host" without any trailing port information implies the default port for the service requested

Was the port different from 80 or 443? I will write a test for it anyway.

sykesm commented 2 years ago

Was the port different from 80 or 443? I will write a test for it anyway.

Yes, that's what I meant by "non-standard port."