Skip to content

Commit 43ad7c5

Browse files
codemeedpgeorge
authored andcommitted
requests: 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 42caaf1 commit 43ad7c5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

python-ecosys/requests/manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.10.1", pypi="requests")
1+
metadata(version="0.10.2", pypi="requests")
22

33
package("requests")

python-ecosys/requests/requests/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ def request(
182182

183183
if redirect:
184184
s.close()
185+
# Use the host specified in the redirect URL, as it may not be the same as the original URL.
186+
headers.pop("Host", None)
185187
if status in [301, 302, 303]:
186188
return request("GET", redirect, None, None, headers, stream)
187189
else:

0 commit comments

Comments
 (0)