]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport Jeremy's fix: req.method should be req.get_method.
authorRaymond Hettinger <python@rcn.com>
Thu, 22 May 2003 17:30:48 +0000 (17:30 +0000)
committerRaymond Hettinger <python@rcn.com>
Thu, 22 May 2003 17:30:48 +0000 (17:30 +0000)
Lib/urllib2.py

index 1c33eb058e13aff6f3d256e24f40a85bb5c94aed..84680d0a32ff2b5ea28110e747bfb661cc3045ec 100644 (file)
@@ -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)