summaryrefslogtreecommitdiffstats
path: root/Lib/urllib2.py
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-02-07 19:06:52 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-02-07 19:06:52 (GMT)
commit86371d61b704958e68bed0f9937c6a1ff5fd766e (patch)
tree2a82d71b84bec8628dc47cd041275aee79344c55 /Lib/urllib2.py
parentb4ee4a16f4fc28d89ba9b139db6cbaace44fc47a (diff)
downloadcpython-86371d61b704958e68bed0f9937c6a1ff5fd766e.zip
cpython-86371d61b704958e68bed0f9937c6a1ff5fd766e.tar.gz
cpython-86371d61b704958e68bed0f9937c6a1ff5fd766e.tar.bz2
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).
Diffstat (limited to 'Lib/urllib2.py')
-rw-r--r--Lib/urllib2.py5
1 files changed, 4 insertions, 1 deletions
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 @@ class HTTPRedirectHandler(BaseHandler):
# 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: