summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorAshwin Ramaswami <aramaswamis@gmail.com>2019-09-13 11:40:08 (GMT)
committerStéphane Wirtel <stephane@wirtel.be>2019-09-13 11:40:07 (GMT)
commitff2e18286560e981f4e09afb0d2448ea994414d8 (patch)
tree9a339486705cfbc5d6b183ffdf11ad686b256b1d /Doc
parentbb41147eab15a2958f4ad38261e5bf608f6ace1b (diff)
downloadcpython-ff2e18286560e981f4e09afb0d2448ea994414d8.zip
cpython-ff2e18286560e981f4e09afb0d2448ea994414d8.tar.gz
cpython-ff2e18286560e981f4e09afb0d2448ea994414d8.tar.bz2
bpo-12707: deprecate info(), geturl(), getcode() methods in favor of headers, url, and status properties for HTTPResponse and addinfourl (GH-11447)
Co-Authored-By: epicfaace <aramaswamis@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/http.client.rst23
-rw-r--r--Doc/library/urllib.request.rst55
2 files changed, 63 insertions, 15 deletions
diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst
index db26d56..a458ab7 100644
--- a/Doc/library/http.client.rst
+++ b/Doc/library/http.client.rst
@@ -484,6 +484,14 @@ statement.
HTTP protocol version used by server. 10 for HTTP/1.0, 11 for HTTP/1.1.
+.. attribute:: HTTPResponse.url
+
+ URL of the resource retrieved, commonly used to determine if a redirect was followed.
+
+.. attribute:: HTTPResponse.headers
+
+ Headers of the response in the form of an :class:`email.message.EmailMessage` instance.
+
.. attribute:: HTTPResponse.status
Status code returned by server.
@@ -501,6 +509,21 @@ statement.
Is ``True`` if the stream is closed.
+.. method:: HTTPResponse.geturl()
+
+ .. deprecated:: 3.9
+ Deprecated in favor of :attr:`~HTTPResponse.url`.
+
+.. method:: HTTPResponse.info()
+
+ .. deprecated:: 3.9
+ Deprecated in favor of :attr:`~HTTPResponse.headers`.
+
+.. method:: HTTPResponse.getstatus()
+
+ .. deprecated:: 3.9
+ Deprecated in favor of :attr:`~HTTPResponse.status`.
+
Examples
--------
diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst
index 448bc67..a903d60 100644
--- a/Doc/library/urllib.request.rst
+++ b/Doc/library/urllib.request.rst
@@ -55,16 +55,8 @@ The :mod:`urllib.request` module defines the following functions:
The *cadefault* parameter is ignored.
This function always returns an object which can work as a
- :term:`context manager` and has methods such as
-
- * :meth:`~urllib.response.addinfourl.geturl` --- return the URL of the resource retrieved,
- commonly used to determine if a redirect was followed
-
- * :meth:`~urllib.response.addinfourl.info` --- return the meta-information of the page, such as headers,
- in the form of an :func:`email.message_from_string` instance (see
- `Quick Reference to HTTP Headers <http://jkorpela.fi/http.html>`_)
-
- * :meth:`~urllib.response.addinfourl.getcode` -- return the HTTP status code of the response.
+ :term:`context manager` and has the properties *url*, *headers*, and *status*.
+ See :class:`urllib.response.addinfourl` for more detail on these properties.
For HTTP and HTTPS URLs, this function returns a
:class:`http.client.HTTPResponse` object slightly modified. In addition
@@ -1585,9 +1577,42 @@ some point in the future.
:synopsis: Response classes used by urllib.
The :mod:`urllib.response` module defines functions and classes which define a
-minimal file like interface, including ``read()`` and ``readline()``. The
-typical response object is an addinfourl instance, which defines an ``info()``
-method and that returns headers and a ``geturl()`` method that returns the url.
-Functions defined by this module are used internally by the
-:mod:`urllib.request` module.
+minimal file-like interface, including ``read()`` and ``readline()``.
+Functions defined by this module are used internally by the :mod:`urllib.request` module.
+The typical response object is a :class:`urllib.response.addinfourl` instance:
+
+.. class:: addinfourl
+
+ .. attribute:: url
+
+ URL of the resource retrieved, commonly used to determine if a redirect was followed.
+
+ .. attribute:: headers
+
+ Returns the headers of the response in the form of an :class:`~email.message.EmailMessage` instance.
+
+ .. attribute:: status
+
+ .. versionadded:: 3.9
+
+ Status code returned by server.
+
+ .. method:: geturl()
+
+ .. deprecated:: 3.9
+ Deprecated in favor of :attr:`~addinfourl.url`.
+
+ .. method:: info()
+
+ .. deprecated:: 3.9
+ Deprecated in favor of :attr:`~addinfourl.headers`.
+
+ .. attribute:: code
+
+ .. deprecated:: 3.9
+ Deprecated in favor of :attr:`~addinfourl.status`.
+
+ .. method:: getstatus()
+ .. deprecated:: 3.9
+ Deprecated in favor of :attr:`~addinfourl.status`.