code wiki / (root) / http_resp.nx

http_resp.nx

buildroot/runtime/http_resp.nx

7238 B198 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic http
docsdependenciesstructsconstsfunctions

about

http_resp.nx -- HTTP/1.1 response generator. Companion to http.nx (request parser). Assembles a valid HTTP response into a caller-mmapped output buffer: status line, headers, body. No internal allocation beyond tiny scratch. Response shape (RFC 7230 ยง3): HTTP-version SP status-code SP reason-phrase CRLF *header-field CRLF CRLF [ message-body ] Implementation notes: - Content-Length automatically emitted from body_len. Chunked transfer encoding is a future extension. - Connection: close emitted by default (no keep-alive yet). - Server: nishi emitted for sovereignty attribution. - Date header NOT emitted -- caller can pre-compute via timefmt.nx if clock sync matters for their use case. Invariants: HR1 Output buffer bounds-checked at every append; overrun returns a negative error rather than silent truncation. HR2 No internal state; each response is built from scratch. Thread-safe for the caller's own isolation concerns. HR3 Status codes + reason phrases kept in a fixed table; no arbitrary int -> string formatting on the response path. HR4 Content-Length header reflects body_len exactly; no mismatched framing that would confuse HTTP/1.1 clients.

dependencies 1 imports · 0 importers

syscalls.nx http_resp.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main http_build_response http_emit_status http_append_cstr http_append_dec http_reason http_emit_header http_append_cstr ↻ http_emit_content_length http_append_cstr ↻ http_append_dec ↻ http_append_cstr ↻ http_append_bytes

structs

none

consts

33const HRR_ERR_OVERFLOW: i64 = -1

functions

41func http_reason(code: i64) -> *u8 {
called by 1: http_emit_status
64func http_append_cstr(out: *u8, pos: *i64, cap: i64, s: *u8) -> i64 {
77func http_append_bytes(out: *u8, pos: *i64, cap: i64,
called by 1: http_build_response
88func http_append_dec(out: *u8, pos: *i64, cap: i64, n: i64) -> i64 {
115func http_emit_status(out: *u8, pos: *i64, cap: i64, code: i64) -> i64 {
129func http_emit_header(out: *u8, pos: *i64, cap: i64,
141func http_emit_content_length(out: *u8, pos: *i64, cap: i64,
157func http_build_response(out: *u8, cap: i64,
188func main() -> i64 {