]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40321: Add missing test, slightly expand documentation (GH-28760)
authorŁukasz Langa <lukasz@langa.pl>
Wed, 6 Oct 2021 15:28:16 +0000 (17:28 +0200)
committerGitHub <noreply@github.com>
Wed, 6 Oct 2021 15:28:16 +0000 (17:28 +0200)
Doc/library/urllib.request.rst
Lib/test/test_urllib2.py
Lib/urllib/request.py
Misc/NEWS.d/next/Library/2021-07-22-21-25-56.bpo-40321.gBlFmw.rst

index 099d74b2d5eab1de266395b1e7f89e66c6fe4147..88e93ba6b002eb26532a3bb432c7446decdb11ac 100644 (file)
@@ -876,13 +876,17 @@ HTTPRedirectHandler Objects
 .. method:: HTTPRedirectHandler.http_error_307(req, fp, code, msg, hdrs)
 
    The same as :meth:`http_error_301`, but called for the 'temporary redirect'
-   response.
+   response. It does not allow changing the request method from ``POST``
+   to ``GET``.
 
 
 .. method:: HTTPRedirectHandler.http_error_308(req, fp, code, msg, hdrs)
 
    The same as :meth:`http_error_301`, but called for the 'permanent redirect'
-   response.
+   response. It does not allow changing the request method from ``POST``
+   to ``GET``.
+
+   .. versionadded:: 3.11
 
 
 .. _http-cookie-processor:
index 9db23e6ce04bd59e249ba640daa0eccdc3be378b..a2b1340e0bf5ba1a617210faf5bb23f3256f6cb7 100644 (file)
@@ -1163,7 +1163,7 @@ class HandlerTests(unittest.TestCase):
         o = h.parent = MockOpener()
 
         # ordinary redirect behaviour
-        for code in 301, 302, 303, 307:
+        for code in 301, 302, 303, 307, 308:
             for data in None, "blah\nblah\n":
                 method = getattr(h, "http_error_%s" % code)
                 req = Request(from_url, data)
@@ -1176,8 +1176,8 @@ class HandlerTests(unittest.TestCase):
                     method(req, MockFile(), code, "Blah",
                            MockHeaders({"location": to_url}))
                 except urllib.error.HTTPError:
-                    # 307 in response to POST requires user OK
-                    self.assertEqual(code, 307)
+                    # 307 and 308 in response to POST require user OK
+                    self.assertIn(code, (307, 308))
                     self.assertIsNotNone(data)
                 self.assertEqual(o.req.get_full_url(), to_url)
                 try:
index 3ba6d926aa8e7625e4a228e2567fb4fa2bdcc245..fd6fc36aee04b39ed53376c2af0166036b03c41c 100644 (file)
@@ -11,7 +11,7 @@ option.  The OpenerDirector is a composite object that invokes the
 Handlers needed to open the requested URL.  For example, the
 HTTPHandler performs HTTP GET and POST requests and deals with
 non-error returns.  The HTTPRedirectHandler automatically deals with
-HTTP 301, 302, 303, 307 and 308 redirect errors, and the
+HTTP 301, 302, 303, 307, and 308 redirect errors, and the
 HTTPDigestAuthHandler deals with digest authentication.
 
 urlopen(url, data=None) -- Basic usage is the same as original
index 1a7dba249c7db03bad9199ae866ca77924e358d6..fede2a0e5e35fbe0609612374895996d88245983 100644 (file)
@@ -1,2 +1,2 @@
-Adds support for HTTP 308 redirects to :mod:`urllib`. Patch by Jochem
-Schulenklopper.
+Adds support for HTTP 308 redirects to :mod:`urllib`. See :rfc:`7538` for
+details. Patch by Jochem Schulenklopper.