kopia lustrzana https://github.com/micropython/micropython-lib
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: 黃昕暐 <meebox@gmail.com>pull/972/head
rodzic
42caaf14de
commit
43ad7c58fd
|
@ -1,3 +1,3 @@
|
||||||
metadata(version="0.10.1", pypi="requests")
|
metadata(version="0.10.2", pypi="requests")
|
||||||
|
|
||||||
package("requests")
|
package("requests")
|
||||||
|
|
|
@ -182,6 +182,8 @@ def request(
|
||||||
|
|
||||||
if redirect:
|
if redirect:
|
||||||
s.close()
|
s.close()
|
||||||
|
# Use the host specified in the redirect URL, as it may not be the same as the original URL.
|
||||||
|
headers.pop("Host", None)
|
||||||
if status in [301, 302, 303]:
|
if status in [301, 302, 303]:
|
||||||
return request("GET", redirect, None, None, headers, stream)
|
return request("GET", redirect, None, None, headers, stream)
|
||||||
else:
|
else:
|
||||||
|
|
Ładowanie…
Reference in New Issue