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