Message91560
I am not sure where we stand with this issue. It seems to be an old one.
urllib2 still claim (as of python 2.6) the following;
# Strictly (according to RFC 2616), 301 or 302 in response
# to a POST MUST NOT cause a redirection without confirmation
# from the user (of urllib2, in this case). In practice,
# essentially all clients do redirect in this case, so we
# do the same.
# be conciliant with URIs containing a space
This is just not true, we don't do the same at all. redirect_request
does not pass data along and it even changes the headers to reflect
content-size, thus behaving perfectly in accordance with RFC.
For those who stumbled upon this page looking for a workaround, this is
how to do: create a new class inheriting from HTTPRedirectHandler and
use this one instead:
class AutomaticHTTPRedirectHandler(urllib2.HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
"""Return a Request or None in response to a redirect.
The default response in redirect_request claims not to
follow directives in RFC 2616 but in fact it does
This class does not and makes handling 302 with POST
possible
"""
m = req.get_method()
if (code in (301, 302, 303, 307) and m in ("GET", "HEAD")
or code in (301, 302, 303) and m == "POST"):
newurl = newurl.replace(' ', '%20')
return urllib2.Request(newurl,
data=req.get_data(),
headers=req.headers,
origin_req_host=req.get_origin_req_host(),
unverifiable=True)
else:
raise urllib2.HTTPError(req.get_full_url(), code, msg,
headers, fp) |
|
Date |
User |
Action |
Args |
2009-08-14 16:41:59 | crocowhile | set | recipients:
+ crocowhile, akuchling, jjlee, jimjjewett, orsenthil, kxroberto, ajaksu2 |
2009-08-14 16:41:59 | crocowhile | set | messageid: <1250268119.12.0.606118382351.issue1424148@psf.upfronthosting.co.za> |
2009-08-14 16:41:57 | crocowhile | link | issue1424148 messages |
2009-08-14 16:41:57 | crocowhile | create | |
|