Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 1 | \section{Standard Module \sectcode{gopherlib}} |
Guido van Rossum | e47da0a | 1997-07-17 16:34:52 +0000 | [diff] [blame] | 2 | \label{module-gopherlib} |
Guido van Rossum | a12ef94 | 1995-02-27 17:53:25 +0000 | [diff] [blame] | 3 | \stmodindex{gopherlib} |
Fred Drake | 1566a1d | 1998-01-07 13:17:20 +0000 | [diff] [blame] | 4 | \indexii{Gopher}{protocol} |
Guido van Rossum | 8675115 | 1995-02-28 17:14:32 +0000 | [diff] [blame] | 5 | |
Fred Drake | 1947991 | 1998-02-13 06:58:54 +0000 | [diff] [blame] | 6 | \setindexsubitem{(in module gopherlib)} |
Guido van Rossum | 8675115 | 1995-02-28 17:14:32 +0000 | [diff] [blame] | 7 | |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 8 | This module provides a minimal implementation of client side of the |
| 9 | the Gopher protocol. It is used by the module \code{urllib} to handle |
| 10 | URLs that use the Gopher protocol. |
| 11 | |
| 12 | The module defines the following functions: |
| 13 | |
Fred Drake | 1566a1d | 1998-01-07 13:17:20 +0000 | [diff] [blame] | 14 | \begin{funcdesc}{send_selector}{selector, host\optional{, port}} |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 15 | Send a \var{selector} string to the gopher server at \var{host} and |
Fred Drake | 1566a1d | 1998-01-07 13:17:20 +0000 | [diff] [blame] | 16 | \var{port} (default \code{70}). Returns an open file object from |
| 17 | which the returned document can be read. |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 18 | \end{funcdesc} |
| 19 | |
Fred Drake | 1566a1d | 1998-01-07 13:17:20 +0000 | [diff] [blame] | 20 | \begin{funcdesc}{send_query}{selector, query, host\optional{, port}} |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 21 | Send a \var{selector} string and a \var{query} string to a gopher |
Fred Drake | 1566a1d | 1998-01-07 13:17:20 +0000 | [diff] [blame] | 22 | server at \var{host} and \var{port} (default \code{70}). Returns an |
| 23 | open file object from which the returned document can be read. |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 24 | \end{funcdesc} |
| 25 | |
| 26 | Note that the data returned by the Gopher server can be of any type, |
| 27 | depending on the first character of the selector string. If the data |
| 28 | is text (first character of the selector is \samp{0}), lines are |
| 29 | terminated by CRLF, and the data is terminated by a line consisting of |
| 30 | a single \samp{.}, and a leading \samp{.} should be stripped from |
Fred Drake | 1566a1d | 1998-01-07 13:17:20 +0000 | [diff] [blame] | 31 | lines that begin with \samp{..}. Directory listings (first character |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 32 | of the selector is \samp{1}) are transferred using the same protocol. |