Skip to content

Commit

Permalink
Use the host in the redirect url, not the one in headers.
Browse files Browse the repository at this point in the history
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: 黃昕暐 <[email protected]>
  • Loading branch information
codemee authored Dec 6, 2024
1 parent e4cf095 commit 822b340
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python-ecosys/requests/requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ def request(

if redirect:
s.close()
# use the Host in the redirect URL
if "Host" in headers:
headers.pop("Host")
if status in [301, 302, 303]:
return request("GET", redirect, None, None, headers, stream)
else:
Expand Down

0 comments on commit 822b340

Please sign in to comment.