nx_h2_server.nx
buildroot/runtime/nx_h2_server.nx
about
nx_h2_server.nx -- TUTOR-BOOTSTRAP SCAFFOLD (Claude, authored under the B1
rung(3) ALPN-h2 SERVER workflow of the R4-H2 HTTP/2-transport ladder), NOT
credited as team self-authoring.
THE HTTP/2 SERVER REQUEST/RESPONSE framer -- the byte-exact SERVER TWIN of
nx_h2_client_over_tls.nx. Given the client's opening bytes (preface + client
SETTINGS + HEADERS wrapping an HPACK GET block), it:
recv: h2_check_preface -> walk frames -> on the first HEADERS, HPACK-decode
the request :method and :path (return them, or < 0 on malformed).
send: emit server SETTINGS + SETTINGS-ACK + HEADERS(:status 200 = HPACK 0x88,
END_HEADERS) + DATA(body, END_STREAM) on stream 1.
The h2 frame bytes ARE the allowed internet boundary (RFC 9113 / 7541 dictate
the octets); the implementation is pure NishiLang -- no nghttp2, no openssl.
FOUNDED ON (composes, does NOT reinvent -- anti-orphan law; imported EXACTLY
ONCE, RC6 double-import avoided):
- nx_h2_conformance.nx (R4-H2-006, GREEN): pulls TRANSITIVELY (its single
import splices nx_h2_flow -> nx_h2_frame -> nx_hpack -> nx_str ->
nx_syscalls, plus nx_h2_stream and nx_tls13_ext) EVERYTHING we need:
h2_check_preface / h2_frame_read_header / the frame WRITERS
(h2_frame_write_settings_empty / _settings_ack / _headers / _data) / the
HPACK DECODERS (hpack_decode_int / hpack_decode_str) / the request-block
BUILDER (h2_build_client_open, h2_build_request_block) for the gate /
tls13_ext_emit_alpn_h2_only + tls13_ext_parse_alpn_selected for the ALPN
KAT / sys_mmap / sys_write / sys_exit / sys_openat_append / sys_close.
Importing nx_h2_frame / nx_hpack / nx_h2_flow / nx_h2_stream / nx_tls13_ext
directly TOO would be the RC6 double-import landmine.
- nx_h2_client_over_tls.nx (B1 rung(2), GREEN): the CLIENT extractor
h2_extract_status_and_body -- the gate feeds OUR server response THROUGH
it to prove the client recovers :status + body byte-exact (it imports
nx_h2_conformance ONCE, so this second import shares the same
include-guarded modules -- no double-import). We do NOT import the tls13
record/session modules here (those belong to the live loopback organ); the
in-memory gate needs only the framing.
BACK-FILL: the team RE-AUTHORS this from the DATA spec
(knowledge/specs/2026-06-13-http2-transport-ladder.md) via the
emitter-of-emitters (X-AUT-006c/e/f); this hand scaffold is the sanctioned
one-time bootstrap only (meter-integrity, mirror nx_h2_conformance.nx:1-4).
dependencies 2 imports · 3 importers
imports: nx_h2_conformance.nxnx_h2_client_over_tls.nx
imported by: _h2_serve_loopback_gate.nxnx_h2_serve.nxnx_h2_serve_multi.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 76 | const H2_METHOD_UNKNOWN: i64 = 0 |
| 77 | const H2_METHOD_GET: i64 = 1 |
| 78 | const H2_METHOD_POST: i64 = 2 |
functions
| 57 | func hs_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } called by 1: main |
| 58 | func hs_putn(v: i64) -> i64 called by 1: main |
| 66 | func hs_fdn(fd: i64, v: i64) -> i64 called by 1: main |
| 106 | func h2_decode_request( |
| 215 | func h2_server_recv_request( |
| 287 | func h2_server_send_response(out: *u8, status: i64, body: *u8, blen: i64) -> i64 |
| 308 | func main() -> i64 |