blob: b0ebcf726e110932d891e246d77e658030d98c0d [file] [log] [blame]
Guido van Rossum470be141995-03-17 16:07:09 +00001\section{Standard Module \sectcode{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
6\renewcommand{\indexsubitem}{(in module gopherlib)}
7
Guido van Rossumcca8d2b1995-03-22 15:48:46 +00008This module provides a minimal implementation of client side of the
9the Gopher protocol. It is used by the module \code{urllib} to handle
10URLs that use the Gopher protocol.
11
12The module defines the following functions:
13
Fred Drake1566a1d1998-01-07 13:17:20 +000014\begin{funcdesc}{send_selector}{selector, host\optional{, port}}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000015Send a \var{selector} string to the gopher server at \var{host} and
Fred Drake1566a1d1998-01-07 13:17:20 +000016\var{port} (default \code{70}). Returns an open file object from
17which the returned document can be read.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000018\end{funcdesc}
19
Fred Drake1566a1d1998-01-07 13:17:20 +000020\begin{funcdesc}{send_query}{selector, query, host\optional{, port}}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000021Send a \var{selector} string and a \var{query} string to a gopher
Fred Drake1566a1d1998-01-07 13:17:20 +000022server at \var{host} and \var{port} (default \code{70}). Returns an
23open file object from which the returned document can be read.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000024\end{funcdesc}
25
26Note that the data returned by the Gopher server can be of any type,
27depending on the first character of the selector string. If the data
28is text (first character of the selector is \samp{0}), lines are
29terminated by CRLF, and the data is terminated by a line consisting of
30a single \samp{.}, and a leading \samp{.} should be stripped from
Fred Drake1566a1d1998-01-07 13:17:20 +000031lines that begin with \samp{..}. Directory listings (first character
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000032of the selector is \samp{1}) are transferred using the same protocol.