Skip to main content

Module client

Module client 

Source
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);
    }
}

Re-exports§

pub use crate::plus::PlusRequest;

Structs§

PlusReply
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§

ClientError
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.

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-menu type so a consumer can route them to a gophermap renderer; unknown types fall back to opaque bytes.