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

Skip to content

Commit 599ac4b

Browse files
committed
Fix Issue17069: Document getcode method in urllib.request.rst
2 parents cd74322 + b98e96a commit 599ac4b

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
@@ -63,16 +63,24 @@ The :mod:`urllib.request` module defines the following functions:
6363
an HTTPS request will not do any verification of the server's
6464
certificate.
6565

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

69-
* :meth:`geturl` --- return the URL of the resource retrieved,
70+
For ftp, file, data urls and requests are explicity handled by legacy
71+
:class:`URLopener` and :class:`FancyURLopener` class, this function returns
72+
an :class:`urllib.response.addinfourl` object which can work as
73+
:term:`context manager` and has methods such as
74+
75+
* :meth:`~urllib.response.addinfourl.geturl` --- return the URL of the resource retrieved,
7076
commonly used to determine if a redirect was followed
7177

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

82+
* :meth:`~urllib.response.addinfourl.getcode` -- return the HTTP status code of the response.
83+
7684
Raises :exc:`URLError` on errors.
7785

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

0 commit comments

Comments
 (0)