Expand description
Gemini wire format: request validation, the response header, and gemtext rendering.
Pure functions, shared by the session loop, the action executor and the tests. The model supplies a status, a line of meta and structured gemtext lines; everything that makes a Gemini response well-formed — the two-digit code, the single space, the CRLF, the 1024-byte meta bound, the body appearing only after a 2x, and gemtext line prefixes that cannot be confused with one another — is decided here.
Structs§
- Gemini
Request - A request that passed validation, as the model sees it.
Enums§
- Gemtext
Error - Why a gemtext line could not be rendered.
- Gemtext
Line - One gemtext line as the model supplies it.
- Request
Refusal - Why a request line was refused before reaching the model, with the response it gets.
- Response
Error - Why a response could not be rendered.
Constants§
- GEMTEXT_
MIME - The MIME type NetGet’s rendered gemtext declares.
- MAX_
META_ BYTES - The longest meta field a response may carry (§“Responses”: META MUST NOT exceed 1024 bytes).
- MAX_
REQUEST_ BYTES - The longest request line this server buffers:
MAX_URL_BYTESplus CRLF. This is the declaredmax_inbound_bytes— a client sends nothing else on a connection. - MAX_
URL_ BYTES - The longest URL a request may carry, in bytes, excluding its CRLF.
- STATUS_
CODES - Every status code the specification defines, with the meta a response gets when the model
leaves it empty. A response header is always
<code> <meta>with a non-empty meta: some clients split the header on whitespace and fail outright on a bare51\r\n.
Functions§
- gemtext_
mime - A
langparameter for the gemtext MIME type: BCP 47 tags, comma-separated. Anything else is dropped rather than written into the header. - leading_
status - The two-digit status a rendered response begins with.
- parse_
request - Validate a request line (without its CRLF).
- percent_
decode - Decode
%XXescapes (and nothing else —+is a plus sign in a Gemini query, which is not form encoding). Invalid escapes are kept literally; invalid UTF-8 is replaced. - render_
gemtext - Render gemtext. Every line ends in LF, which the specification allows and every client reads.
- render_
response - Render a complete response: header, and the body only for a 2x.