gh-99730: urllib.request: Keep HEAD method on redirect (GH-99731)

This commit is contained in:
Harmen Stoppels 2024-05-01 18:01:47 +02:00 committed by GitHub
parent 49baa656cb
commit 759e8e7ab8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 0 deletions

View file

@ -650,6 +650,7 @@ class HTTPRedirectHandler(BaseHandler):
newheaders = {k: v for k, v in req.headers.items()
if k.lower() not in CONTENT_HEADERS}
return Request(newurl,
method="HEAD" if m == "HEAD" else "GET",
headers=newheaders,
origin_req_host=req.origin_req_host,
unverifiable=True)