Public Access
G1 step 2: Gemini parsers (host-tested), and the memory decision (Q86)
lib/gemini: URLs split per RFC 3986 appendix B and resolved per section 5.2 (all 32 reference examples of 5.4 pass, with gemini:// for http://), the request form (no fragment, lower-case host, never an empty path), query encoding for input prompts, Saved Page paths; the response header (status, category, MIME type and parameters, 1024-byte meta limit); gemtext's line types; and display text for the Latin-1 fonts. 12 tests. Q86, decided after step 1: free heap stays above 40 KB in steady state and 20 KB during a handshake; a fetch won't start below 55 KB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace roro::gemini {
|
||||
|
||||
enum class Category { Input, Success, Redirect, TemporaryFailure, PermanentFailure, ClientCertificate, Unknown };
|
||||
|
||||
// The response header: "<two digits> <meta>", at most 1024 bytes of meta.
|
||||
struct Header {
|
||||
int status = 0;
|
||||
std::string meta;
|
||||
|
||||
Category category() const;
|
||||
bool sensitiveInput() const { return status == 11; }
|
||||
// 2x: the MIME type, lower-cased, without parameters ("text/gemini" when meta is empty).
|
||||
std::string mimeType() const;
|
||||
std::string parameter(const std::string& name) const; // e.g. "charset"
|
||||
};
|
||||
|
||||
bool parseHeader(const std::string& line, Header& out);
|
||||
|
||||
} // namespace roro::gemini
|
||||
Reference in New Issue
Block a user