Skip to content

Commit 822b340

Browse files
authored
Use the host in the redirect url, not the one in headers.
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]>
1 parent e4cf095 commit 822b340

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

python-ecosys/requests/requests/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ def request(
180180

181181
if redirect:
182182
s.close()
183+
# use the Host in the redirect URL
184+
if "Host" in headers:
185+
headers.pop("Host")
183186
if status in [301, 302, 303]:
184187
return request("GET", redirect, None, None, headers, stream)
185188
else:

0 commit comments

Comments
 (0)