summaryrefslogtreecommitdiffstats
path: root/Doc/library/urllib.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-01-20 11:43:03 (GMT)
committerGeorg Brandl <georg@python.org>2008-01-20 11:43:03 (GMT)
commit9b0d46db115c10767b240a0a64286214b50fe6ad (patch)
tree7ecec7b9261dfc50941932036aaec79af5a0a1ce /Doc/library/urllib.rst
parentdcd6b522060d9b14e26046519770e718e65802cd (diff)
downloadcpython-9b0d46db115c10767b240a0a64286214b50fe6ad.zip
cpython-9b0d46db115c10767b240a0a64286214b50fe6ad.tar.gz
cpython-9b0d46db115c10767b240a0a64286214b50fe6ad.tar.bz2
#1178141: add addinfourl.code to get http status code from urllib.
Diffstat (limited to 'Doc/library/urllib.rst')
-rw-r--r--Doc/library/urllib.rst14
1 files changed, 9 insertions, 5 deletions
diff --git a/Doc/library/urllib.rst b/Doc/library/urllib.rst
index 1856cca..3ec6e88 100644
--- a/Doc/library/urllib.rst
+++ b/Doc/library/urllib.rst
@@ -27,16 +27,17 @@ High-level interface
a server somewhere on the network. If the connection cannot be made the
:exc:`IOError` exception is raised. If all went well, a file-like object is
returned. This supports the following methods: :meth:`read`, :meth:`readline`,
- :meth:`readlines`, :meth:`fileno`, :meth:`close`, :meth:`info` and
+ :meth:`readlines`, :meth:`fileno`, :meth:`close`, :meth:`info`, :meth:`getcode` and
:meth:`geturl`. It also has proper support for the :term:`iterator` protocol. One
caveat: the :meth:`read` method, if the size argument is omitted or negative,
may not read until the end of the data stream; there is no good way to determine
that the entire stream from a socket has been read in the general case.
- Except for the :meth:`info` and :meth:`geturl` methods, these methods have the
- same interface as for file objects --- see section :ref:`bltin-file-objects` in
- this manual. (It is not a built-in file object, however, so it can't be used at
- those few places where a true built-in file object is required.)
+ Except for the :meth:`info`, :meth:`getcode` and :meth:`geturl` methods,
+ these methods have the same interface as for file objects --- see section
+ :ref:`bltin-file-objects` in this manual. (It is not a built-in file object,
+ however, so it can't be used at those few places where a true built-in file
+ object is required.)
.. index:: module: mimetools
@@ -58,6 +59,9 @@ High-level interface
the client was redirected to. The :meth:`geturl` method can be used to get at
this redirected URL.
+ The :meth:`getcode` method returns the HTTP status code that was sent with the
+ response, or ``None`` if the URL is no HTTP URL.
+
If the *url* uses the :file:`http:` scheme identifier, the optional *data*
argument may be given to specify a ``POST`` request (normally the request type
is ``GET``). The *data* argument must be in standard