Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b98e96a

Browse files
committed
Fix Issue17069: Document getcode method in urllib.request.rst
1 parent 1acaf0b commit b98e96a

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

Doc/library/urllib.request.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,24 @@ The :mod:`urllib.request` module defines the following functions:
5757
If neither *cafile* nor *capath* is specified, an HTTPS request
5858
will not do any verification of the server's certificate.
5959

60-
This function returns a file-like object that works as a :term:`context manager`,
61-
with two additional methods from the :mod:`urllib.response` module
60+
For http and https urls, this function returns a
61+
:class:`http.client.HTTPResponse` object which has the following
62+
:ref:`httpresponse-objects` methods.
6263

63-
* :meth:`geturl` --- return the URL of the resource retrieved,
64+
For ftp, file, data urls and requests are explicity handled by legacy
65+
:class:`URLopener` and :class:`FancyURLopener` class, this function returns
66+
an :class:`urllib.response.addinfourl` object which can work as
67+
:term:`context manager` and has methods such as
68+
69+
* :meth:`~urllib.response.addinfourl.geturl` --- return the URL of the resource retrieved,
6470
commonly used to determine if a redirect was followed
6571

66-
* :meth:`info` --- return the meta-information of the page, such as headers,
72+
* :meth:`~urllib.response.addinfourl.info` --- return the meta-information of the page, such as headers,
6773
in the form of an :func:`email.message_from_string` instance (see
6874
`Quick Reference to HTTP Headers <http://www.cs.tut.fi/~jkorpela/http.html>`_)
6975

76+
* :meth:`~urllib.response.addinfourl.getcode` -- return the HTTP status code of the response.
77+
7078
Raises :exc:`URLError` on errors.
7179

7280
Note that ``None`` may be returned if no handler handles the request (though

0 commit comments

Comments
 (0)