Gopher

Gopher selector strings are, in general, interpreted as a sequence of 8-bit bytes which may contain any characters other than tab, return, or linefeed. It is necessary to encode any characters disallowed in a URL, including spaces and other binary data not in the allowed character set, using the standard convention of the "%" character followed by two hexadecimal digits.

Note that slash "/" in gopher selector strings may not correspond to a level in a hierarchical structure.

The format of a gopher URL is:

If the URL does not refer to a Gopher+ item and if there is no gopher search string then parts 3, 4, 5, and 6 of the URL are optional When a Gopher server returns a directory listing to a client, Gopher+ items are tagged with either a "+" (denoting gopher+ items) or a "?" (denoting items which have a +ASK form associated with them). A Gopher+ string which is only a "+" refers to the default view (data representation) of the item. To retrieve this item a gopher+ client should send
       a_gopher_selector<tab>+<cr><lf>

to the gopher+ server.

Note that items which have a +ASK asssociated with them (ie. Gopher+ items tagged with a "?") require the client to fetch the item's +ASK attribute to get the form definition, and then ask the user to fill out the form and return the user's responces along with the selector string to retrieve the item. Gopher+ clients know how to do this but depend on the "?" tag in the gopher+ item description to know when to handle this case. The "?" is used in the Gopher+ string to be consistent with Gopher+ protocol's use of this symbol.

To refer to the Gopher+ attributes of an item, the Gopher+ string shall consist of "!" or "$". "!" refers to the all of a gopher+ item's attributes. "$" refers to all the item attributes for all items in a Gopher directory. To retrieve an item or directory's attributes, a gopher client will send:

       a_gopher_selector<tab>!<cr><lf>

for items or
       a_gopher_selector<tab>$<cr><lf>

for directories to the gopher+ server.

To refer to specific attributes, the Gopher+ string is "!attribute_name" or "$attribute_name". For example, to refer to the attribute containing the abstract of an item, the Gopher+ string would be "!+ABSTRACT". To refer to several attributes, clients send the server the attribute names seperated by spaces so it is neccesary to seperate the attribute names with coded spaces. To retrieve a collection of item attributes specified with a gopher+ string of "!+ABSTRACT%20+SMELL" a gopher client would send

       a_gopher_selector<tab>!+ABSTRACT +SMELL<cr><lf>

to the gopher server.

Gopher+ allows for optional alternate data representations (alternate views) of items. To retrieve a Gopher+ alternate view, the gopher+ client sends the appropriate view and language identifier (found in the item's +VIEW attribute). To refer to a specific Gopher+ alternate view, the URL's Gopher+ string would be in the form "+view_name%20language_name". For example, a gopher+ string of "+application/postscript%20Es_ES" refers to the spanish language postscript alternate view of a gopher+ item. To retrieve this alternate view the client would send

       a_gopher_selector<tab>+application/postscript Es_ES<cr><lf>

to the gopher server.

The gopher+ string for a URL that refers to an item referenced by an ASK form filled out with specific values is essentially a coded version of what the client sends to the server. The gopher+ string will be of the form

  +%091%0D%0A+-1%0D%0Aask_item1_value%0D%0Aask_item2_value%0D%0A.%0D%0A 

To retrieve this item, the gopher client sends:
       a_gopher_selector<tab>+<tab>1<cr><lf>
       +-1<cr><lf>
       ask_item1_value<cr><lf>
       ask_item2_value<cr><lf>
       .<cr><lf>

to the gopher server.

For a really complex example, consider a URL that refers to an alternate view of an item that is referenced with a filled-out Gopher +ASK form. The gopher+ string will be of the form:

 
    +view_name%20language_name%091%0D%0A+-1%0D%0Aask_item1_value%0D%0A
    ask_item2_value%0D%0A.%0D%0A 

To retrieve this item, the gopher client sends:
       a_gopher_selector<tab>+view_name language_name<tab>1<cr><lf>
       +-1<cr><lf>
       ask_item1_value<cr><lf>
       ask_item2_value<cr><lf>
       .<cr><lf>

to the gopher server.

Summary: gopher+ string part of Gopher URL

To refer to an item which has an ASK form associated with it where the intent is to allow the user to enter values into the form as part of the retrieval process:
   %3F  


To refer to all or specific attributes of a gopher item:
   ![attribute_name][%20attribute_name][%20attribute_name]...


To refer to all or specific attributes of a gopher directory:
   $[attribute_name][%20attribute_name][%20attribute_name]...


To refer to the content of a gopher+ item (including an item referred to by specific values in a filled-out ASK form):
   +[view_name[%20language_name]]
    [%091%0D%0A+-1%0D%0Aask_item1_value%0D%0Aask_item2_value...%0D%0A.%0D%0A]



Overall summary and examples

The general format of a Gopher URL path refering to a gopher type "T" item is:
  gopher://host [port]/T[gopher_selector]%09[search_string]%09[gopher+_string]


Examples:

An example of a URL pointing to a gopher type 0 item (a document) is:
  gopher://host [port]/0a_gopher_selector


An example of a URL pointing to a gopher type 7 item (a search engine) where the string foobar is to be submitted to the search engine is:
  gopher://host [port]/7a_gopher_selector%09foobar


An example of a URL pointing to a Gopher+ type 0 item (a document) is:
  gopher://host [port]/0a_gopher_selector%09%09some_gplus_stuff


An example of a URL pointing to a Gopher+ type 0 (document) item's attribute information is:
  gopher://host [port]/0a_gopher_selector%09%09!


An example of a URL pointing to a Gopher+ document's spanish postscript representation is:
  gopher://host [port]/0a_gopher_selector%09%09+application/postscript%20Es_ES

.