code wiki / (root) / nx_http.nx

nx_http.nx

buildroot/runtime/nx_http.nx

11022 B300 linesdepth 2pulls 2 transitivereach 9 importersview sourcekind tooltopic http
docsdependenciesstructsconstsfunctions

about

http.nx -- HTTP/1.1 request parser (RFC 7230/9112 subset). Parses an HTTP request from a byte buffer (typically accumulated from socket reads). Reader-only subset: - Request line: METHOD SP path SP HTTP/1.1 CRLF - Headers: Name ": " Value CRLF (until empty line) - Body: remaining bytes per Content-Length Response generation is the caller's job; we provide a typed view of the request + a Content-Length header lookup helper. Real-world HTTP servers add: chunked transfer, keep-alive, HTTP/2 framing, pipelining. Those are future work. Invariants: H1 All reads bounds-check against caller-supplied buffer end. H2 Header parsing stops at CRLF CRLF (empty line) per RFC 7230 ยง3. H3 Returns offsets into the caller's buffer; nothing copied. Parser struct owns only position metadata. H4 Malformed input returns negative HTTP_ERR_*; no silent acceptance of weird forms (e.g. bare LF line ends).

dependencies 1 imports · 7 importers

nx_syscalls.nx nx_http.nx nx_browser_view_serve.nx nx_pages_daemon.nx nx_pages_http_redirect.nx nx_pages_https_daemon.nx nx_pages_vhost.nx nx_pages_vhost_debug.nx nx_pages_vhost_test.nx

imports: nx_syscalls.nx

imported by: nx_browser_view_serve.nxnx_pages_daemon.nxnx_pages_http_redirect.nxnx_pages_https_daemon.nxnx_pages_vhost.nxnx_pages_vhost_debug.nxnx_pages_vhost_test.nx

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

main sys_mmap http_parse http_request_init sys_mmap ↻ http_parse_request_line http_scan_token_end http_skip_hspace http_find_crlf http_parse_headers http_skip_hspace ↻ http_find_crlf ↻ http_get_header http_header_name_eq

structs

43struct HttpRequest

consts

32const HTTP_ERR_TRUNCATED: i64 = -1
33const HTTP_ERR_BAD_METHOD: i64 = -2
34const HTTP_ERR_BAD_VERSION: i64 = -3
35const HTTP_ERR_BAD_HEADER: i64 = -4
36const HTTP_ERR_TOO_MANY_HDR: i64 = -5
38const HTTP_MAX_HEADERS: i64 = 64

functions

58func http_request_init(req: *HttpRequest) -> i64
called by 2: http_parsemain calls 1: sys_mmap
73func http_scan_token_end(buf: *u8, pos: i64, end: i64) -> i64
87func http_skip_hspace(buf: *u8, pos: i64, end: i64) -> i64
109func http_find_crlf(buf: *u8, pos: i64, end: i64) -> i64
124func http_parse_request_line(buf: *u8, end: i64, req: *HttpRequest) -> i64
159func http_parse_headers(buf: *u8, start: i64, end: i64,
230func http_parse(buf: *u8, n: i64, req: *HttpRequest) -> i64
244func http_header_name_eq(buf: *u8, off: i64, len: i64,
called by 1: http_get_header
265func http_get_header(buf: *u8, req: *HttpRequest, name: *u8,
281func main() -> i64