diff options
author | Facundo Batista <facundobatista@gmail.com> | 2007-03-23 18:54:07 (GMT) |
---|---|---|
committer | Facundo Batista <facundobatista@gmail.com> | 2007-03-23 18:54:07 (GMT) |
commit | 07c78be0b4723deb62acebab50888cc59b1e4eb2 (patch) | |
tree | 0d1da08d12eafe4ac485889e1aac891e035c0696 /Doc/lib | |
parent | f102e24bd34442026f4200a298a8b08d1deb3616 (diff) | |
download | cpython-07c78be0b4723deb62acebab50888cc59b1e4eb2.zip cpython-07c78be0b4723deb62acebab50888cc59b1e4eb2.tar.gz cpython-07c78be0b4723deb62acebab50888cc59b1e4eb2.tar.bz2 |
Added a 'create_connect()' function to socket.py, which creates a
connection with an optional timeout, and modified httplib.py to
use this function in HTTPConnection. Applies patch 1676823.
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libhttplib.tex | 14 | ||||
-rw-r--r-- | Doc/lib/libsocket.tex | 9 |
2 files changed, 21 insertions, 2 deletions
diff --git a/Doc/lib/libhttplib.tex b/Doc/lib/libhttplib.tex index 557ee3d..67371a4 100644 --- a/Doc/lib/libhttplib.tex +++ b/Doc/lib/libhttplib.tex @@ -26,18 +26,28 @@ that use HTTP and HTTPS. The module provides the following classes: -\begin{classdesc}{HTTPConnection}{host\optional{, port}} +\begin{classdesc}{HTTPConnection}{host\optional{, port\optional{, + strict\optional{, timeout}}}} An \class{HTTPConnection} instance represents one transaction with an HTTP server. It should be instantiated passing it a host and optional port number. If no port number is passed, the port is extracted from the host string if it has the form \code{\var{host}:\var{port}}, else the default HTTP port (80) is -used. For example, the following calls all create instances that connect to +used. +When True the optional parameter \var{strict} +causes \code{BadStatusLine} to be raised if the status line can't be parsed +as a valid HTTP/1.0 or 1.1 status line. If the optional \var{timeout} +parameter is given, connection attempts will timeout after that many +seconds (if no timeout is passed, or is passed as None, the global default +timeout setting is used). + +For example, the following calls all create instances that connect to the server at the same host and port: \begin{verbatim} >>> h1 = httplib.HTTPConnection('www.cwi.nl') >>> h2 = httplib.HTTPConnection('www.cwi.nl:80') >>> h3 = httplib.HTTPConnection('www.cwi.nl', 80) +>>> h3 = httplib.HTTPConnection('www.cwi.nl', 80, timeout=10) \end{verbatim} \versionadded{2.0} \end{classdesc} diff --git a/Doc/lib/libsocket.tex b/Doc/lib/libsocket.tex index e0ce0a5..c63b52b 100644 --- a/Doc/lib/libsocket.tex +++ b/Doc/lib/libsocket.tex @@ -170,6 +170,15 @@ supported on this platform. \versionadded{2.3} \end{datadesc} +\begin{funcdesc}{create_connection}{address\optional{, timeout}} +Connects to the \var{address} received (as usual, a pair host/port), with +an optional timeout for the connection. Specially useful for higher-level +protocols, it is not normally used directly from application-level code. +Passing the optional \var{timeout} parameter will set the timeout on the +socket instance (if not present, or passed as None, the global default +timeout setting is used). +\end{funcdesc} + \begin{funcdesc}{getaddrinfo}{host, port\optional{, family\optional{, socktype\optional{, proto\optional{, flags}}}}} |