Gopher client tests (URLs)
These tests check how well your Gopher client handles gopher
URLs per RFC 4266[1] and RFC 3986[2]. (Obviously, if your
client doesn't support Gopher URLs, these tests are moot.)
Copy and paste each URL in to your client. If your client
does not properly handle a URL, the result page will report
what the server both received and expected.
------------------------------------------------------------
Path info tests
------------------------------------------------------------
gopher://asciz.com/1/client-tests/pathinfo/foo/%20%252525%23text
gopher://asciz.com/1/client-tests/pathinfo/foo%2F%20%252525%23text
gopher://asciz.com/1/client-tests/pathinfo/foo/%20%252525%23text#fragment
gopher://asciz.com/1/client-tests/pathinfo/foo%2F%20%252525%23text#fragment
(You may be wondering why these URLs contain "%252525". I
use the same test endpoints for both URL tests (this page)
and selector tests (see below). At least one Gopher client
unescapes percent-encoded bytes _in a selector_ (contrary
to RFC 1436, which says "[t]he selector string ... should
never be modified by the client"). The Gopher server that
I'm running also unescapes percent-encoded bytes in the
path portion of a request; a "%25" in a selector would be
unescaped to "%" by the aforementioned unfortunate client,
and the server would attempt to unescape "%", resulting in
a "bad selector" error. So I use "%2525" in the selectors,
which must be percent-encoded as "%252525" in URLs, to allow
this test script to provide some useful information about
what went wrong with the request.)
(The same unfortunate client also strips off anything
following a "#" in a selector, which is further damage to
the selector.)
------------------------------------------------------------
Query string tests
------------------------------------------------------------
gopher://asciz.com/1/client-tests/query1/?query%20string%25%23text
gopher://asciz.com/1/client-tests/query1/%3Fquery%20string%25%23text
gopher://asciz.com/1/client-tests/query2/?query%20string%25?%23text
gopher://asciz.com/1/client-tests/query2/%3Fquery%20string%25%3F%23text
------------------------------------------------------------
Search string tests
------------------------------------------------------------
gopher://asciz.com/1/client-tests/search/%09search%20string%25/?%23text
gopher://asciz.com/1/client-tests/search/%09search%20string%25%2F%3F%23text
------------------------------------------------------------
These tests as Gopher selectors
------------------------------------------------------------
gopher://asciz.com/1/client-tests/menu
------------------------------------------------------------
Proper handling of Gopher URLs
------------------------------------------------------------
According to RFC 4266, a Gopher URL takes the form:
gopher://<host>:<port>/<gopher-path>
where <gopher-path> is one of:
<gophertype><selector>
<gophertype><selector>%09<search>
Per RFC 4266 and RFC 3986, the URL must be percent-encoded
(but note that the <TAB> byte that separates the <selector>
from the <search> is already percent-encoded in the above
description and should not be encoded a second time).
To properly handle a Gopher URL, a client must decode
percent-encoded bytes in the <gopher-path> (e.g., %2F
decodes to /) and then send the decoded bytes to the Gopher
server. It also must NOT handle most "special" characters,
such as ? or /, differently from any other character; the
Gopher protocol does not reserve these and treats them as
regular characters.
On the other hand, RFC 3986 specifies that a number sign
("#") is used to delimit a fragment and that:
the fragment identifier is separated from the rest of
the URI prior to a dereference, and thus the identifying
information within the fragment itself is dereferenced
solely by the user agent, regardless of the URI scheme.
(from RFC 3986 section 3.5.)
Therefore if a number sign is part of a selector, it must be
percent-encoded in a Gopher URL, and a client must decode
it and send it as a number sign to the Gopher server. On
the other hand, if the number sign is used to delimit a
fragment, it must NOT be percent-encoded in a Gopher URL,
and a client must NOT send the number sign nor the fragment
identifier to the Gopher server.
Note: This script uses "path info" and/or a "query string"
(a la CGI) in the various tests above to identify what is
being tested. These are purely server-side constructs as
the Gopher protocol itself has no concept of them; however,
a client must send the full selector, unmodified, to the
server which allows the server to handle them as expected.
------------------------------------------------------------
References
------------------------------------------------------------
[1]
gopher://asciz.com/0/rfc/rfc4266.txt
[2]
gopher://asciz.com/0/rfc/rfc3986.txt