Skip to content

Commit 954b9ad

Browse files
committed
Document new urllib features by Eric Raymond.
1 parent 9ab96d4 commit 954b9ad

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

Doc/lib/liburllib.tex

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,17 @@ \section{\module{urllib} ---
3737
required.)
3838

3939
The \method{info()} method returns an instance of the class
40-
\class{mimetools.Message} containing the headers received from the
41-
server, if the protocol uses such headers (currently the only
42-
supported protocol that uses this is HTTP). See the description of
43-
the \module{mimetools}\refstmodindex{mimetools} module.
40+
\class{mimetools.Message} containing meta-information associated
41+
with the URL. When the method is HTTP, these headers are those
42+
returned by the server at the head of the retrieved HTML page
43+
(including Content-Length and Content-Type). When the method is FTP,
44+
a Content-Length header will be present if (as is now usual) the
45+
server passed back a file length in response to the FTP retrieval
46+
request. When the method is local-file, returned headers will include
47+
a Date representing the file's last-modified time, a Content-Length
48+
giving file size, and a Content-Type containing a guess at the file's
49+
type. See also the description of the
50+
\module{mimetools}\refstmodindex{mimetools} module.
4451

4552
If the \var{url} uses the \file{http:} scheme identifier, the optional
4653
\var{data} argument may be given to specify a \code{POST} request
@@ -50,7 +57,7 @@ \section{\module{urllib} ---
5057

5158
\end{funcdesc}
5259

53-
\begin{funcdesc}{urlretrieve}{url}
60+
\begin{funcdesc}{urlretrieve}{url\optional{, filename}\optional{, hook}}}
5461
Copy a network object denoted by a URL to a local file, if necessary.
5562
If the URL points to a local file, or a valid cached copy of the
5663
object exists, the object is not copied. Return a tuple
@@ -60,6 +67,16 @@ \section{\module{urllib} ---
6067
\method{info()} method of the object returned by \function{urlopen()}
6168
returned (for a remote object, possibly cached). Exceptions are the
6269
same as for \function{urlopen()}.
70+
71+
The second argument, if present, specifies the file location to copy
72+
to (if absent, the location will be a tempfile with a generated name).
73+
The third argument, if present, is a hook function that will be called
74+
once on establishment of the network connection and once after each
75+
block read thereafter. The hook will be passed three arguments; a
76+
count of blocks transferred so far, a block size in bytes, and the
77+
total size of the file. The third argument may be -1 on older FTP
78+
servers which do not return a file size in response to a retrieval
79+
request.
6380
\end{funcdesc}
6481

6582
\begin{funcdesc}{urlcleanup}{}

0 commit comments

Comments
 (0)