Fixes Issue 1401. When redirected, a possible POST get converted
to GET, so it loses its payload. So, it also must lose the
headers related to the payload (if it has no content any more,
it shouldn't indicate content length and type).
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index 8bf0884..d5a539d 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -534,8 +534,11 @@
# do the same.
# be conciliant with URIs containing a space
newurl = newurl.replace(' ', '%20')
+ newheaders = dict((k,v) for k,v in req.headers.items()
+ if k.lower() not in ("content-length", "content-type")
+ )
return Request(newurl,
- headers=req.headers,
+ headers=newheaders,
origin_req_host=req.get_origin_req_host(),
unverifiable=True)
else: