mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
bpo-40321: Add missing test, slightly expand documentation (GH-28760)
This commit is contained in:
parent
61892c0476
commit
f528045f69
4 changed files with 12 additions and 8 deletions
|
@ -876,13 +876,17 @@ HTTPRedirectHandler Objects
|
||||||
.. method:: HTTPRedirectHandler.http_error_307(req, fp, code, msg, hdrs)
|
.. method:: HTTPRedirectHandler.http_error_307(req, fp, code, msg, hdrs)
|
||||||
|
|
||||||
The same as :meth:`http_error_301`, but called for the 'temporary redirect'
|
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)
|
.. method:: HTTPRedirectHandler.http_error_308(req, fp, code, msg, hdrs)
|
||||||
|
|
||||||
The same as :meth:`http_error_301`, but called for the 'permanent redirect'
|
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:
|
.. _http-cookie-processor:
|
||||||
|
|
|
@ -1163,7 +1163,7 @@ class HandlerTests(unittest.TestCase):
|
||||||
o = h.parent = MockOpener()
|
o = h.parent = MockOpener()
|
||||||
|
|
||||||
# ordinary redirect behaviour
|
# 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":
|
for data in None, "blah\nblah\n":
|
||||||
method = getattr(h, "http_error_%s" % code)
|
method = getattr(h, "http_error_%s" % code)
|
||||||
req = Request(from_url, data)
|
req = Request(from_url, data)
|
||||||
|
@ -1176,8 +1176,8 @@ class HandlerTests(unittest.TestCase):
|
||||||
method(req, MockFile(), code, "Blah",
|
method(req, MockFile(), code, "Blah",
|
||||||
MockHeaders({"location": to_url}))
|
MockHeaders({"location": to_url}))
|
||||||
except urllib.error.HTTPError:
|
except urllib.error.HTTPError:
|
||||||
# 307 in response to POST requires user OK
|
# 307 and 308 in response to POST require user OK
|
||||||
self.assertEqual(code, 307)
|
self.assertIn(code, (307, 308))
|
||||||
self.assertIsNotNone(data)
|
self.assertIsNotNone(data)
|
||||||
self.assertEqual(o.req.get_full_url(), to_url)
|
self.assertEqual(o.req.get_full_url(), to_url)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -11,7 +11,7 @@ option. The OpenerDirector is a composite object that invokes the
|
||||||
Handlers needed to open the requested URL. For example, the
|
Handlers needed to open the requested URL. For example, the
|
||||||
HTTPHandler performs HTTP GET and POST requests and deals with
|
HTTPHandler performs HTTP GET and POST requests and deals with
|
||||||
non-error returns. The HTTPRedirectHandler automatically 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.
|
HTTPDigestAuthHandler deals with digest authentication.
|
||||||
|
|
||||||
urlopen(url, data=None) -- Basic usage is the same as original
|
urlopen(url, data=None) -- Basic usage is the same as original
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
Adds support for HTTP 308 redirects to :mod:`urllib`. Patch by Jochem
|
Adds support for HTTP 308 redirects to :mod:`urllib`. See :rfc:`7538` for
|
||||||
Schulenklopper.
|
details. Patch by Jochem Schulenklopper.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue