# Gopher (protocol)

The Gopher protocol (/ˈɡoʊfər/ ) is a communication protocol designed for distributing, searching, and retrieving documents in Internet Protocol networks. The design of the Gopher protocol and user interface is menu-driven, and presented an alternative to the World Wide Web in its early stages, but ultimately fell into disfavor, yielding to Hypertext Transfer Protocol (HTTP). The Gopher ecosystem is often regarded as the effective predecessor of the World Wide Web.

## Usage

The Gopher protocol was invented by a team led by Mark P. McCahill at the University of Minnesota. It offers some features not natively supported by the Web and imposes a much stronger hierarchy on the documents it stores. Its text menu interface is well-suited to computing environments that rely heavily on remote text-oriented computer terminals, which were still common at the time of its creation in 1991, and the simplicity of its protocol facilitated a wide variety of client implementations.
* Firefox 1.5 (2005)
Gopher's hierarchical structure provided a platform for the first large-scale electronic library connections. The Gopher protocol is still in use by enthusiasts, and although it has been almost entirely supplanted by the Web, a small population of actively-maintained servers remains.

### Origins

The Gopher system was released in mid-1991 by Mark P. McCahill, Farhad Anklesaria, Paul Lindner, Daniel Torrey, and Bob Alberti of the University of Minnesota in the United States. Its central goals were, as stated in RFC 1436:
* A file-like hierarchical arrangement that would be familiar to users.
* A simple syntax.
* A system that can be created quickly and inexpensively.
* Extensibility of the file system metaphor; allowing addition of searches for example.
Gopher combines document hierarchies with collections of services, including WAIS, the Archie and Veronica search engines, and gateways to other information systems such as File Transfer Protocol (FTP) and Usenet.
The general interest in campus-wide information systems (CWISs) in higher education at the time, and the ease of setup of Gopher servers to create an instant CWIS with links to other sites' online directories and resources, were the factors contributing to Gopher's rapid adoption.
The name was coined by Anklesaria as a play on several meanings of the word "gopher". The University of Minnesota mascot is the gopher, a gofer is an assistant who "goes for" things, and a gopher burrows through the ground to reach a desired location.

### Decline

The World Wide Web was in its infancy in 1991, and Gopher services quickly became established. By the late 1990s, Gopher had ceased expanding. Several factors contributed to Gopher's stagnation:
* In February 1993, the University of Minnesota announced that it would charge licensing fees for the use of its implementation of the Gopher server. Users became concerned that fees might also be charged for independent implementations. Gopher expansion stagnated, to the advantage of the World Wide Web, to which CERN disclaimed ownership. In September 2000, the University of Minnesota re-licensed its Gopher software under the GNU General Public License.
* Gopher client functionality was quickly duplicated by the early Mosaic web browser, which subsumed its protocol.
* Gopher has a more rigid structure than the free-form HyperText Markup Language (HTML) of the Web. Every Gopher document has a defined format and type, and the typical user navigates through a single server-defined menu system to get to a particular document. This can be quite different from the way a user finds documents on the Web.
* Failure to follow the open systems model and bad publicity in comparison to the World Wide Web
Gopher remains in active use by its enthusiasts, and there have been attempts to revive Gopher on modern platforms and mobile devices. One attempt is The Overbite Project, which hosts various browser extensions and modern clients.

### Server census

* As of 2012, there remained about 160 gopher servers indexed by Veronica-2, reflecting a slow growth from 2007 when there were fewer than 100. They are typically infrequently updated. On these servers, Veronica indexed approximately 2.5 million unique selectors. A handful of new servers were being set up every year by hobbyists with over 50 having been set up and added to Floodgap's list since 1999. A snapshot of Gopherspace in 2007 circulated on BitTorrent and was still available in 2010. Due to the simplicity of the Gopher protocol, setting up new servers or adding Gopher support to browsers is often done in a tongue-in-cheek manner, principally on April Fools' Day.
* In November 2014 Veronica indexed 144 gopher servers, reflecting a small drop from 2012, but within these servers Veronica indexed approximately 3 million unique selectors.
* In March 2016 Veronica indexed 135 gopher servers, within which it indexed approximately 4 million unique selectors.
* In March 2017 Veronica indexed 133 gopher servers, within which it indexed approximately 4.9 million unique selectors.
* In May 2018 Veronica indexed 260 gopher servers, within which it indexed approximately 3.7 million unique selectors.
* In May 2019 Veronica indexed 320 gopher servers, within which it indexed approximately 4.2 million unique selectors.
* In January 2020 Veronica indexed 395 gopher servers, within which it indexed approximately 4.5 million unique selectors.
* In February 2021 Veronica indexed 361 gopher servers, within which it indexed approximately 6 million unique selectors.
* In February 2022 Veronica indexed 325 gopher servers, within which it indexed approximately 5 million unique selectors.

## Technical details

The conceptualization of knowledge in "Gopher space" or a "cloud" as specific information in a particular file, and the prominence of the FTP, influenced the technology and the resulting functionality of Gopher.

### Gopher characteristics

Gopher is designed to function and to appear much like a mountable read-only global network file system (and software, such as gopherfs, is available that can actually mount a Gopher server as a FUSE resource). At a minimum, whatever can be done with data files on a CD-ROM, can be done on Gopher.
A Gopher system consists of a series of hierarchical hyperlinkable menus. The choice of menu items and titles is controlled by the administrator of the server.
Similar to a file on a Web server, a file on a Gopher server can be linked to as a menu item from any other Gopher server. Many servers take advantage of this inter-server linking to provide a directory of other servers that the user can access.

### Protocol

The Gopher protocol was first described in RFC 1436. Internet Assigned Numbers Authority (IANA) has assigned Transmission Control Protocol (TCP) port 70 to the Gopher protocol. The protocol is simple to negotiate, making it possible to browse without using a client.

#### User request

First, the client establishes a TCP connection with the server on port 70, the standard gopher port. The client then sends a string followed by a carriage return followed by a line feed (a "CR + LF" sequence). This is the selector, which identifies the document to be retrieved. If the item selector were an empty line, the default directory would be selected.

#### Server response

The server then replies with the requested item and closes the connection. According to the protocol, before the connection closes, the server should send a full-stop (i.e., a period character) on a line by itself. However, not all servers conform to this part of the protocol and the server may close a connection without returning a final full-stop. The main type of reply from the server is a text or binary resource. Alternatively, the resource can be a menu: a form of structured text resource providing references to other resources.
Because of the simplicity of the Gopher protocol, tools such as netcat make it possible to download Gopher content easily from a command line:
The protocol is also supported by cURL since 7.21.2-DEV, which was released in 2010.

#### Search request

The selector string in the request can optionally be followed by a tab character and a search string. This is used by item type 7.

### Source code of a menu

Gopher menu items are defined by lines of tab-separated values in a text file. This file is sometimes called a gophermap. As the source code to a gopher menu, a gophermap is roughly analogous to an HTML file for a web page. Each tab-separated line (called a selector line) gives the client software a description of the menu item: what it is, what it is called, and where it leads to. The client displays the menu items in the order that they appear in the gophermap.
The first character in a selector line indicates the item type, which tells the client what kind of file or protocol the menu item points to. This helps the client decide what to do with it. Gopher's item types are a more basic precursor to the media type system used by the Web and email attachments.
The item type is followed by the user display string (a description or label that represents the item in the menu); the selector (a path or other string for the resource on the server); the hostname (the domain name or IP address of the server), and the network port.
All lines in a gopher menu are terminated by "CR + LF".
Example of a selector line in a menu source: The following selector line generates a link to the "/home" directory at the subdomain gopher.floodgap.com, on port 70. The item type of 1 indicates that the linked resource is a Gopher menu itself. The string "Floodgap Home" is what the client will show to the user when visiting the example menu.
| Item type | User display string | Selector | Hostname | Port |
| 1 | Floodgap Home | /home | gopher.floodgap.com | 70 |

#### Item types

In a Gopher menu's source code, a one-character code indicates what kind of content the client should expect. This code may either be a digit or a letter of the alphabet; letters are case-sensitive.
The technical specification for Gopher, RFC 1436, defines 14 item types. The later gopher+ specification defined an additional 3 types. A one-character code indicates what kind of content the client should expect. Item type 3 is an error code for exception handling. Gopher client authors improvised item types h (HTML), i (informational message), and s (sound file) after the publication of RFC 1436. Browsers like Netscape Navigator and early versions of Microsoft Internet Explorer would prepend the item type code to the selector as described in RFC 4266, so that the type of the gopher item could be determined by the url itself. Most gopher browsers still available, use these prefixes in their urls.
Canonical types :
| 0 | Text file |
| 1 | Gopher submenu |
| 2 | CCSO Nameserver |
| 3 | Error code returned by a Gopher server to indicate failure |
| 4 | BinHex-encoded file (primarily for Macintosh computers) |
| 5 | DOS file |
| 6 | uuencoded file |
| 7 | Gopher full-text search |
| 8 | Telnet |
| 9 | Binary file |
| + | Mirror or alternate server (for load balancing or in case of primary server downtime) |
| g | GIF file |
| I | Image file |
| T | Telnet 3270 |
| gopher+ types ||
| : | Bitmap image |
| ; | Movie file |
| < | Sound file |
| Non-canonical types ||
| d | Doc. Seen used alongside PDF and .doc files |
| h | HTML file |
| i | Informational message, widely used. |
| p | image file "(especially the PNG format)" |
| r | document RTF file ("Rich Text Format") |
| s | Sound file (especially the WAV format) |
| P | PDF (Portable Document Format) file |
| X | XML (Extensible Markup Language) file |
Here is an example gopher session where the user requires a gopher menu (/Reference on the first line):
The gopher menu sent back from the server, is a sequence of lines each of which describes an item that can be retrieved. Most clients will display these as hypertext links, and so allow the user to navigate through gopherspace by following the links. This menu includes a text resource (itemtype 0 on the third line), multiple links to submenus (itemtype 1, on the second line as well as lines 4–6) and a non-standard information message (from line 7 on), broken down to multiple lines by providing dummy values for selector, host and port.

#### External links

Historically, to create a link to a Web server, "GET /" was used as a pseudo-selector to emulate an HTTP GET request. John Goerzen created an addition to the Gopher protocol, commonly referred to as "URL links", that allows links to any protocol that supports URLs. For example, to create a link to http://gopher.quux.org/, the item type is h, the display string is the title of the link, the item selector is "URL:http://gopher.quux.org/", and the domain and port are that of the originating Gopher server (so that clients that do not support URL links will query the server and receive an HTML redirection page).

### Gopher+

Gopher+ is a forward compatible enhancement to the Gopher protocol. Gopher+ works by sending metadata between the client and the server. The enhancement was never widely adopted by Gopher servers. The client sends a tab followed by a +. A Gopher+ server will respond with a status line followed by the content the client requested. An item is marked as supporting Gopher+ in the Gopher directory listing by a tab + after the port (this is the case of some of the items in the example above).
Other features of Gopher+ include:
* Item attributes, which can include the items
** Administrator
** Last date of modification
** Different views of the file, like PostScript or plain text, or different languages
** Abstract, or description of the item
* Interactive queries

## Client software
### Gopher clients

These are clients, libraries, and utilities primarily designed to access gopher resources.
| Client | Updated | License | Language | Type | Notes |
| ACID | 2021 | ? | C | GUI (Windows) | Supports page cache, TFTP and has G6 extension. |
| Bombadillo | 2022 | GPLv3 | Go | TUI (Linux, BSD, macOS) | Supports Gopher, Gemini, Finger |
| cURL | 2024 | | C | CLI | |
| elpher | 2022 | GPLv3 | Emacs Lisp | TUI/GUI | Elpher: a gopher, finger, and gemini client for GNU Emacs |
| eva | 2022 | GPLv3 | Rust | GUI | Eva (as in extra vehicular activity, or spacewalk) is a Gemini and Gopher protocol browser in GTK 4. |
| Gopher Browser | 2019 | Closed source | VB.NET | GUI (Windows) | |
| Gopher Client | 2018 | | | App (iOS) | Supports text reflow, bookmarks, history, etc. |
| gophercle | 2022 | MIT | Java | App (Android) | Supports only basic functionalities like bookmarks, session-history, downloads, etc. |
| Gopherus | 2020 | BSD 2-clause | C | TUI (Linux, BSD, Windows, DOS) | Features bookmarks and page caching. |
| Gophie | 2020 | GPLv3 | Java | GUI (Windows, MacOS, Linux) | |
| Kristall | 2020 | GPLv3 | C++ | GUI (Linux) | Gemini GUI client with support for Gopher, Finger, and www. |
| Lagrange | 2022 | BSD 2-clause | C | GUI | Gemini GUI client with Gopher and finger support. Switches to gophermap/type 1 requests in parent/root navigation. |
| Little Gopher Client | 2019 | | Pascal | Linux, Mac, Windows | Sidebar with a hierarchical view |
| ncgopher | 2022 | BSD 2-clause | Rust | TUI | ncgopher is a gopher and gemini client using ncurses. |
| Pocket Gopher | 2019 | Unlicense | Java | App (Android) | Supports bookmarks, history, downloads, etc. |
| sacc | 2022 | | C | TUI | sacc(omys) is a terminal gopher client. |
| snarf | 2020 | GPL | C | CLI | Simple Non-interactive All-purpose Resource Fetcher |
| w3m | 2021 | MIT | C | TUI | w3m is a text-based web browser |

### Other clients

Clients like web browsers, libraries, and utilities primarily designed to access World Wide Web resources, but which maintain(ed) gopher support.
* Browse, a browser for RISC OS
* Camino, versions 1.0 to 2.1.2, always uses port 70.
* Classilla, versions 9.0 to 9.3.4b1 as of March 2021, hardcoded to port 70 from 9.0 to 9.2; whitelisted ports from 9.2.1
* Dillo+
* Dooble
* ELinks, versions 0.10.0 to 0.12pre6 as of October 2012, unmaintained browser with gopher build option. Fork felinks offers support as a build option
* Edbrowse, a line-oriented editor and browser with an interface like that of ed (text editor)
* Falkon, with plug-in only, requires Falkon ≥ 3.1.0 with both the KDE Frameworks Integration extension (shipped with Falkon ≥ 3.1.0) enabled and the (separate) kio_gopher plug-in ≥ 0.1.99 (first release for KDE Frameworks 5) installed
* Mozilla Firefox versions 0.1 to 3.6, built-in support dropped from Firefox 4.0 onwards; can be added back by installing one of the extensions by the Overbite Project
* Galeon version 2.0.7
* Google Chrome, with extension only, Burrow extension
* Internet Explorer for Mac version 5.2.3, PowerPC-only
* Internet Explorer, dropped with version 6: Support removed by MS02-047 from IE 6 SP1 can be re-enabled in the Windows Registry. Always uses port 70. Gopher support was disabled in Internet Explorer versions 5.x and 6 for Windows in August 2002 by a patch meant to fix a security vulnerability in the browser's Gopher protocol handler to reduce the attack surface which was included in IE6 SP1; however, it can be re-enabled by editing the Windows registry. In Internet Explorer 7, Gopher support was removed on the WinINET level.
* K-Meleon, dropped support
* Konqueror, with plug-in only, requires kio_gopher plug-in
* Line Mode Browser, since version 1.1, January 1992
* Lynx
* Mosaic, version 3.0
* NetSurf, under development, based on the cURL fetcher
* Netscape Navigator, version 9.0.0.6
* OmniWeb, since version 5.9.2 (April 2009), first WebKit Browser to support Gopher
* Opera, Opera 9.0 included a proxy capability
* Pavuk, a web mirror (recursive download) software program
* SeaMonkey, version 1.0 to 2.0.14, built-in support dropped from version 2.1 onward; could be added back to some versions via Overbite project, but no longer supported.
* Epiphany, until version 2.26.3, disabled with switch to WebKit
* WebPositive, a WebKit-based browser used in the Haiku operating system
* libwww, versions 1.0c (December 1992) to 5.4.1 December 2006, libwww is a discontinued API for internet applications. A modern fork is maintained in Lynx
Browsers with no Gopher native support can still access servers using one of the available Gopher to HTTP gateways or proxy server that converts Gopher menus into HTML; known proxies are the Floodgap Public Gopher proxy and Gopher Proxy. Similarly, certain server packages such as GN and PyGopherd have built-in Gopher to HTTP interfaces. Squid Proxy software gateways any gopher:// URL to HTTP content, enabling any browser or web agent to access gopher content easily.
For Mozilla Firefox and SeaMonkey, Overbite extensions extend Gopher browsing and support the current versions of the browsers (Firefox Quantum v ≥57 and equivalent versions of SeaMonkey):
* OverbiteWX redirects gopher:// URLs to a proxy;
* OverbiteNX adds native-like support;
* for Firefox up to 56.*, and equivalent versions of SeaMonkey, OverbiteFF adds native-like support, but it is no longer maintained
OverbiteWX includes support for accessing Gopher servers not on port 70 using a whitelist and for CSO/ph queries. OverbiteFF always uses port 70. For Chromium and Google Chrome, Burrow is available. It redirects gopher:// URLs to a proxy. In the past an Overbite proxy-based extension for these browsers was available but is no longer maintained and does not work with the current (>23) releases. For Konqueror, Kio gopher is available.
As the bandwidth-sparing simple interface of Gopher can be a good match for mobile phones and personal digital assistants (PDAs), the early 2010s saw a renewed interest in native Gopher clients for popular smartphones.
Gopher popularity was at its height at a time when there were still many equally competing computer architectures and operating systems. As a result, there are several Gopher clients available for Acorn RISC OS, AmigaOS, Atari MiNT, Conversational Monitor System (CMS), DOS, classic Mac OS, MVS, NeXT, OS/2 Warp, most Unix-like operating systems, VMS, Windows 3.x, and Windows 9x. GopherVR was a client designed for 3D visualization, and there is even a Gopher client in MOO. Most such clients are hard-coded to work on Transmission Control Protocol (TCP) port 70.

## Server software

Because the protocol is trivial to implement in a basic fashion, there are many server packages still available, and some are still maintained.
| Server | Developed by | Latest version | Release date | License | Written in | Notes |
| Aftershock | Rob Linwood | 1.0.1 | 22 April 2004 | MIT | Java | |
| Apache::GopherHandler | Timm Murray | 0.1 | 26 March 2004 | GPLv2 or any later version | Perl | Apache 2 plugin to run Gopher-Server. |
| Atua | Charles Childers | 2017.4 | 9 October 2017 | ISC | Forth | |
| Bucktooth (gopher link) (proxied link) | Cameron Kaiser | 0.2.10 | 10 February 2024 | Floodgap Free Software License | Perl | |
| Flask-Gopher | Michael Lazar | 2.2.1 | 11 April 2020 | GPLv3 | Python | |
| geomyid | Quinn Evans | 0.0.1 | 10 August 2015 | BSD 2-clause | Common Lisp | |
| geomyidae (gopher link) (proxied link) | Christoph Lohmann | 0.96 | 26 August 2022 | MIT | C | REST dynamic scripting, gopher TLS support, compatibility layer for other gophermaps |
| GoFish | Sean MacLennan | 1.2 | 8 October 2010 | GPLv2 | C | |
| go-gopher | James Mills | | 31 March 2022 | MIT | Go | |
| Gopher-Server | Timm Murray | 0.1.1 | 26 March 2004 | GPLv2 | Perl | |
| Gophernicus | Kim Holviala and others | 3.1.1 | 3 January 2021 | BSD 2-clause | C | |
| gophrier | Guillaume Duhamel | 0.2.3 | 29 March 2012 | GPLv2 | C | |
| Goscher | Aaron W. Hsu | 8.0 | 20 June 2011 | ISC | Scheme | |
| mgod | Mate Nagy | 1.1 | 29 January 2018 | GPLv3 | C | |
| Motsognir | Mateusz Viste | 1.0.13 | 8 January 2021 | MIT | C | extensible through custom gophermaps, CGI and PHP scripts |
| Pituophis | dotcomboom | 1.1 | 16 May 2020 | BSD 2-clause | Python | Python-based Gopher library with both server and client support |
| PyGopherd | Michael Lazar | 3.0.1 | 25 February 2024 | GPLv2 | Python | Also supports HTTP, WAP, and Gopher+ |
| Redis | Salvatore Sanfilippo | 6.2.5 | 21 July 2021 | 3-clause BSD | C | Support removed in version 7 |
| save_gopher_server | SSS8555 | 0.777 | 7 July 2020 | ? | Perl | with G6 extension and TFTP |
| Spacecookie | Lukas Epple | 1.0.0.0 | 17 March 2021 | GPLv3 | Haskell | |
| Xylophar | Nathaniel Leveck | 0.0.1 | 15 January 2020 | GPLv3 | FreeBASIC | |