python-ecosys/requests/requests/__init__.py: Use the host in the redirect url, not the one in headers.#942
Closed
codemee wants to merge 5 commits intomicropython:masterfrom
Closed
python-ecosys/requests/requests/__init__.py: Use the host in the redirect url, not the one in headers.#942codemee wants to merge 5 commits intomicropython:masterfrom
codemee wants to merge 5 commits intomicropython:masterfrom
Conversation
The host in headers extracted from the original url may not be the same as the host in the redirect url. Poping out the host in headers force the code to use the host in the redirect url, otherwise the redirect may fail due to inconsistence of hosts in the original url and the redirect url. Signed-off-by: 黃昕暐 <meebox@gmail.com>
dpgeorge
reviewed
Apr 10, 2025
| s.close() | ||
| # use the Host in the redirect URL | ||
| if "Host" in headers: | ||
| headers.pop("Host") |
Member
There was a problem hiding this comment.
I think you could use headers.pop("Host", None) here to make it a little more efficient.
Use `headers.pop("Host", None)` instead of a `if` statement.
Signed-off-by: 黃昕暐 <meebox@gmail.com>
… "Host" header in the redirect URL Update the comment to explain the reason for poping out "Host" header from headers. Ths host in the redirect URL may not be the same as the original URL, pop out "Host" in headers before redirect would force using the host specified in the redirect URL. Signed-off-by: 黃昕暐 <meebox@gmail.com>
Update the comment to explain the reason for poping out "Host" header from headers. Ths host in the redirect URL may not be the same as the original URL, pop out "Host" in headers before redirect would force using the host specified in the redirect URL. Signed-off-by: 黃昕暐 <meebox@gmail.com>
dpgeorge
approved these changes
Apr 11, 2025
Member
dpgeorge
left a comment
There was a problem hiding this comment.
Thanks for updating, looks good now.
Member
|
Rebased and merged in 43ad7c5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
removing the host header when redirect
The host in headers extracted from the original url may not be the same as the host in the redirect url. It shoud use the host in the redirect url, not the one in the headers.