blob: 156d6d76fd2681cc074286183dca600f2c110fa4 [file] [log] [blame]
Fred Drake3a0351c1998-04-04 07:23:21 +00001\section{Standard Module \module{gopherlib}}
Guido van Rossume47da0a1997-07-17 16:34:52 +00002\label{module-gopherlib}
Guido van Rossuma12ef941995-02-27 17:53:25 +00003\stmodindex{gopherlib}
Fred Drake1566a1d1998-01-07 13:17:20 +00004\indexii{Gopher}{protocol}
Guido van Rossum86751151995-02-28 17:14:32 +00005
Guido van Rossum86751151995-02-28 17:14:32 +00006
Guido van Rossumcca8d2b1995-03-22 15:48:46 +00007This module provides a minimal implementation of client side of the
8the Gopher protocol. It is used by the module \code{urllib} to handle
9URLs that use the Gopher protocol.
10
11The module defines the following functions:
12
Fred Drake1566a1d1998-01-07 13:17:20 +000013\begin{funcdesc}{send_selector}{selector, host\optional{, port}}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000014Send a \var{selector} string to the gopher server at \var{host} and
Fred Drake1566a1d1998-01-07 13:17:20 +000015\var{port} (default \code{70}). Returns an open file object from
16which the returned document can be read.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000017\end{funcdesc}
18
Fred Drake1566a1d1998-01-07 13:17:20 +000019\begin{funcdesc}{send_query}{selector, query, host\optional{, port}}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000020Send a \var{selector} string and a \var{query} string to a gopher
Fred Drake1566a1d1998-01-07 13:17:20 +000021server at \var{host} and \var{port} (default \code{70}). Returns an
22open file object from which the returned document can be read.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000023\end{funcdesc}
24
25Note that the data returned by the Gopher server can be of any type,
26depending on the first character of the selector string. If the data
27is text (first character of the selector is \samp{0}), lines are
28terminated by CRLF, and the data is terminated by a line consisting of
29a single \samp{.}, and a leading \samp{.} should be stripped from
Fred Drake1566a1d1998-01-07 13:17:20 +000030lines that begin with \samp{..}. Directory listings (first character
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000031of the selector is \samp{1}) are transferred using the same protocol.