blob: 4b22605314ad57bc16b78ad45191cb461663dad7 [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
Georg Brandlb56230b2006-02-17 11:18:58 +00007\deprecated{2.5}{The \code{gopher} protocol is not in active use
8 anymore.}
9
Fred Drake1566a1d1998-01-07 13:17:20 +000010\indexii{Gopher}{protocol}
Guido van Rossum86751151995-02-28 17:14:32 +000011
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000012This module provides a minimal implementation of client side of the
Raymond Hettinger7e431102003-09-22 15:00:55 +000013Gopher protocol. It is used by the module \refmodule{urllib} to
Fred Drakebcd54541999-04-22 16:17:45 +000014handle URLs that use the Gopher protocol.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000015
16The module defines the following functions:
17
Fred Drake1566a1d1998-01-07 13:17:20 +000018\begin{funcdesc}{send_selector}{selector, host\optional{, port}}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000019Send a \var{selector} string to the gopher server at \var{host} and
Fred Drake1566a1d1998-01-07 13:17:20 +000020\var{port} (default \code{70}). Returns an open file object from
21which the returned document can be read.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000022\end{funcdesc}
23
Fred Drake1566a1d1998-01-07 13:17:20 +000024\begin{funcdesc}{send_query}{selector, query, host\optional{, port}}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000025Send a \var{selector} string and a \var{query} string to a gopher
Fred Drake1566a1d1998-01-07 13:17:20 +000026server at \var{host} and \var{port} (default \code{70}). Returns an
27open file object from which the returned document can be read.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000028\end{funcdesc}
29
30Note that the data returned by the Gopher server can be of any type,
31depending on the first character of the selector string. If the data
32is text (first character of the selector is \samp{0}), lines are
33terminated by CRLF, and the data is terminated by a line consisting of
34a single \samp{.}, and a leading \samp{.} should be stripped from
Fred Drake1566a1d1998-01-07 13:17:20 +000035lines that begin with \samp{..}. Directory listings (first character
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000036of the selector is \samp{1}) are transferred using the same protocol.