Expand description
The gopher client (gopher://, port 70).
A gopher URL is gopher://host/<type><selector>: the first path character is
the item type, the rest is the selector sent verbatim. The request is just
the selector and a CRLF; a type-7 search appends the query after a TAB.
Gopher has no status line. Every reply is a body, and the item type is the only hint about what the bytes are, so the client reports a best-effort MIME alongside them rather than inventing a status the protocol lacks.
let reply = gopher_protocol::fetch("gopher://gopher.floodgap.com/1/").await?;
if reply.mime == "application/gopher-menu" {
for item in gopher_protocol::parse_menu(&String::from_utf8_lossy(&reply.body)) {
println!("{:?} {}", item.kind, item.display);
}
}Structs§
- Plus
Reply - A Gopher+ reply: the header the server declared, and the body with any period terminator removed.
- Response
- One gopher reply: the body, plus the MIME inferred from the item type.
Enums§
- Client
Error - What can go wrong fetching a gopher resource. There is no protocol-error variant because gopher has no status line: a server that dislikes a request answers with an error item inside an ordinary menu body.
- Plus
Request - What a Gopher+ retrieval asks for.
Constants§
- DEFAULT_
PORT - Gopher’s well-known port.
Functions§
- fetch
- Fetch a
gopher://URL. - fetch_
attributes - Fetch and parse an item’s Gopher+ attribute blocks (
!). - fetch_
directory_ attributes - Fetch and parse the attribute blocks of every item in a directory (
$). - fetch_
plus - Run a Gopher+ transaction against a
gopher://URL. - mime_
for_ item_ type - A best-effort MIME type for a gopher item type. Menus get an
application/gopher-menutype so a consumer can route them to a gophermap renderer; unknown types fall back to opaque bytes.