Message154516
I've noticed that urllib2's HTTPRedirectHandler does not redirect a POST request with the POST data.
If you send a POST request to a server with data, the data is dropped when the new Request is made to the new url. As stated in a comment in the library itself, redirecting a POST request is not strictly RFC compliant, but it's generally supported anyway. The problem here being that our POST data is not also being redirected. I ran into this issue when writing a web api wrapper in Python.
I'm submitting a small patch that fixes this issue:
--- /usr/lib/python2.7/urllib2.py 2011-10-04 16:07:28.000000000 -0500
+++ urllib2.py 2012-02-27 16:03:36.000000000 -0600
@@ -551,7 +551,11 @@
newheaders = dict((k,v) for k,v in req.headers.items()
if k.lower() not in ("content-length", "content-type")
)
+ data = None
+ if req.has_data():
+ data = req.get_data()
return Request(newurl,
+ data=data,
headers=newheaders,
origin_req_host=req.get_origin_req_host(),
unverifiable=True) |
|
Date |
User |
Action |
Args |
2012-02-27 22:44:09 | crustymonkey | set | recipients:
+ crustymonkey |
2012-02-27 22:44:09 | crustymonkey | set | messageid: <1330382649.62.0.524230876085.issue14144@psf.upfronthosting.co.za> |
2012-02-27 22:44:09 | crustymonkey | link | issue14144 messages |
2012-02-27 22:44:08 | crustymonkey | create | |
|