Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{gopherlib} --- |
| 2 | Gopher protocol client.} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | \declaremodule{standard}{gopherlib} |
| 4 | |
| 5 | \modulesynopsis{Gopher protocol client (requires sockets).} |
| 6 | |
Fred Drake | 1566a1d | 1998-01-07 13:17:20 +0000 | [diff] [blame] | 7 | \indexii{Gopher}{protocol} |
Guido van Rossum | 8675115 | 1995-02-28 17:14:32 +0000 | [diff] [blame] | 8 | |
Guido van Rossum | 8675115 | 1995-02-28 17:14:32 +0000 | [diff] [blame] | 9 | |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 10 | This module provides a minimal implementation of client side of the |
| 11 | the Gopher protocol. It is used by the module \code{urllib} to handle |
| 12 | URLs that use the Gopher protocol. |
| 13 | |
| 14 | The module defines the following functions: |
| 15 | |
Fred Drake | 1566a1d | 1998-01-07 13:17:20 +0000 | [diff] [blame] | 16 | \begin{funcdesc}{send_selector}{selector, host\optional{, port}} |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 17 | 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] | 18 | \var{port} (default \code{70}). Returns an open file object from |
| 19 | which the returned document can be read. |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 20 | \end{funcdesc} |
| 21 | |
Fred Drake | 1566a1d | 1998-01-07 13:17:20 +0000 | [diff] [blame] | 22 | \begin{funcdesc}{send_query}{selector, query, host\optional{, port}} |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 23 | 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] | 24 | server at \var{host} and \var{port} (default \code{70}). Returns an |
| 25 | open file object from which the returned document can be read. |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 26 | \end{funcdesc} |
| 27 | |
| 28 | Note that the data returned by the Gopher server can be of any type, |
| 29 | depending on the first character of the selector string. If the data |
| 30 | is text (first character of the selector is \samp{0}), lines are |
| 31 | terminated by CRLF, and the data is terminated by a line consisting of |
| 32 | a single \samp{.}, and a leading \samp{.} should be stripped from |
Fred Drake | 1566a1d | 1998-01-07 13:17:20 +0000 | [diff] [blame] | 33 | lines that begin with \samp{..}. Directory listings (first character |
Guido van Rossum | cca8d2b | 1995-03-22 15:48:46 +0000 | [diff] [blame] | 34 | of the selector is \samp{1}) are transferred using the same protocol. |