From: Raymond Hettinger Date: Thu, 22 May 2003 17:30:48 +0000 (+0000) Subject: Backport Jeremy's fix: req.method should be req.get_method. X-Git-Tag: v2.2.3c1~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a74d9fe777e04bd5a493cbe615b353b70079b73b;p=thirdparty%2FPython%2Fcpython.git Backport Jeremy's fix: req.method should be req.get_method. --- diff --git a/Lib/urllib2.py b/Lib/urllib2.py index 1c33eb058e13..84680d0a32ff 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -416,12 +416,14 @@ class HTTPRedirectHandler(BaseHandler): None if you can't but another Handler might. """ - if (code in (301, 302, 303, 307) and req.method() in ("GET", "HEAD") or - code in (302, 303) and req.method() == "POST"): - # Strictly (according to RFC 2616), 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. + m = req.get_method() + if (code in (301, 302, 303, 307) and m in ("GET", "HEAD") + or code in (302, 303) and m == "POST"): + # Strictly (according to RFC 2616), 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. return Request(newurl, headers=req.headers) else: raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)