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

Clear host header for cross-domain redirection #32

Closed
VoidMonk opened this issue May 24, 2017 · 1 comment
Closed

Clear host header for cross-domain redirection #32

VoidMonk opened this issue May 24, 2017 · 1 comment

Comments

@VoidMonk
Copy link

Found a minor issue: if a request redirects from hostname A to hostname B, then the host header from the previous request must be cleared, else it will return a HTTP error 404 (or similar) from the destination server of hostname B.

Example httpbin test URL: https://httpbin.org/redirect-to?url=http%3A%2F%2Fexample.com%2F (redirects from httpbin.org to example.com).

Possible fix: add delete opts.headers['host'] to clear previous request's host header in parseOptsUrl() around line 103.

As a sidenote, you probably don't need delete opts.url in parseOptsUrl() at line 103. Should be safe to keep opts.url.

@feross
Copy link
Owner

feross commented Apr 24, 2018

For what it's worth, request opted to not fix this issue, i.e. to leave the Host header intact on redirects. But I think it's more sensible to remove it. psf/requests#2366

Fixed in 2.7.1.

feross added a commit that referenced this issue Apr 24, 2018
@feross feross closed this as completed in 1ec2322 Apr 24, 2018
feross added a commit that referenced this issue Apr 24, 2018
- clearer code when detecting if a custom 'accept-encoding' header is being used.

- allows any casing of `Host`/`host`/`HoSt` header to be removed upon redirect, making the fix to #32 more robust
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