blob: 820f63dfee6947716cbab116615057dbc8121be9 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{gopherlib} ---
Fred Drakebcd54541999-04-22 16:17:45 +00002 Gopher protocol client}
Fred Drakeb91e9341998-07-23 17:59:49 +00003
Fred Drakebcd54541999-04-22 16:17:45 +00004\declaremodule{standard}{gopherlib}
Fred Drakeb91e9341998-07-23 17:59:49 +00005\modulesynopsis{Gopher protocol client (requires sockets).}
6
Fred Drake1566a1d1998-01-07 13:17:20 +00007\indexii{Gopher}{protocol}
Guido van Rossum86751151995-02-28 17:14:32 +00008
Guido van Rossumcca8d2b1995-03-22 15:48:46 +00009This module provides a minimal implementation of client side of the
Raymond Hettinger7e431102003-09-22 15:00:55 +000010Gopher protocol. It is used by the module \refmodule{urllib} to
Fred Drakebcd54541999-04-22 16:17:45 +000011handle URLs that use the Gopher protocol.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000012
13The module defines the following functions:
14
Fred Drake1566a1d1998-01-07 13:17:20 +000015\begin{funcdesc}{send_selector}{selector, host\optional{, port}}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000016Send a \var{selector} string to the gopher server at \var{host} and
Fred Drake1566a1d1998-01-07 13:17:20 +000017\var{port} (default \code{70}). Returns an open file object from
18which the returned document can be read.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000019\end{funcdesc}
20
Fred Drake1566a1d1998-01-07 13:17:20 +000021\begin{funcdesc}{send_query}{selector, query, host\optional{, port}}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000022Send a \var{selector} string and a \var{query} string to a gopher
Fred Drake1566a1d1998-01-07 13:17:20 +000023server at \var{host} and \var{port} (default \code{70}). Returns an
24open file object from which the returned document can be read.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000025\end{funcdesc}
26
27Note that the data returned by the Gopher server can be of any type,
28depending on the first character of the selector string. If the data
29is text (first character of the selector is \samp{0}), lines are
30terminated by CRLF, and the data is terminated by a line consisting of
31a single \samp{.}, and a leading \samp{.} should be stripped from
Fred Drake1566a1d1998-01-07 13:17:20 +000032lines that begin with \samp{..}. Directory listings (first character
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000033of the selector is \samp{1}) are transferred using the same protocol.