Security record: HTTP/1.1 — the parser, the server and its carriers, WebSocket

The record of nish/net/http1-codec (the incremental request parser and the response writers), nish/net/http1-server (the server side of a connection, and its two carriers: plain TCP on nish:net and TLS on nish/net/tls-tcp with ALPN http/1.1) and nish/net/websocket (RFC 6455 framing and the opening handshake, both the server's accept and the client's request and check of the server's answer).

It says what each refuses and with what, what it caps and where the cap is set, what it keeps in memory and for how long, and the test that pins each property. It is written with the code rather than after an audit, so that the audit of the protocol stack starts from evidence.

Result. Every request-smuggling shape RFC 9112 names is refused, never repaired, and the refusal is answered with its status and a close; none is a panic. A panic is only ever the program's own mistake (a window outside its buffer, a cap out of range). Every cap is a number the program fixes at start-up. A warmed slot serves request after request — heads, bodies either way, responses with a length or chunked — with Arena.used() flat, over plain TCP and over TLS.

H1-1 (Medium), a client that trickles the bytes of its head to keep its slot, is fixed by a deadline for the whole head. H1-5 (Medium), a response written at H1_END framed from a head already reset, is fixed by holding the head until the next request is asked for. H1-2 (Low), a refusal closed at once over plain TCP, is fixed by a lingering close bounded in time and bytes. H1-8 (Medium), a chunk extension skipped rather than parsed, so that a quoted-string run across the line's end framed the body differently from a front end that reads it, is fixed by parsing its RFC 9112 §7.1.1 grammar whole. H1-9 (Low), a Host value never read, is fixed by refusing one that is not uri-host [":" port] with 400. H1-10 (Low), a WebSocket handshake whose Origin nothing read, is answered by an opt-in check, websocketOriginAllowed, a program makes before accepting. H1-3 (Low), the memory each WebSocket upgrade left in the arena, is fixed: a slot hashes the key and writes the 101 into storage it keeps. The client's side of the handshake refuses every answer RFC 6455 §4.1 tells a client to fail, each with its own WS_HS_* code; it adds no finding.

Scope

File Functions
std/net/http1-codec.ts Http1Parser (feed, next, restart, the span accessors header, headerIndex, headerIs, methodIs, targetIs, upgradeIs, buffered, resting) and its helpers (http1TakeLine, http1RequestLine, http1FieldLine, http1EndOfHead (with nish/net/url's urlIsHostPort for the Host value), http1Tally, http1ContentLength, http1ChunkSize, http1ChunkExtValid, http1QuotedStringEnd, http1SkipOws, http1BodyWindow, http1HeadAppend, http1HeadGrow, http1FramingField); the writers http1ResponseHead, http1WriteResponseHead, http1Chunk, http1WriteChunk, http1LastChunk
std/net/http1-server.ts Http1Connection: feed, inputRoom, next, nextRequest, nextFrame, fail, respond, write, sendBody, end, acceptWebSocket, sendFrame, closeWebSocket, sendPong, sendClose, restart, acquire, release, park, unpark; the kept response head (sameHead, keepHead, http1ServerKept, http1ServerSame8, http1ServerSame4, http1ServerSameByByte); Http1OutputPool (take, give); Http1Server and Http1TlsServer: accept, readable, writable, next, flush, send, close, expire, refused; Http1Server.rearm; HttpDate (current, pin, unpin)
std/net/http-fields.ts httpDateWrite and its helpers (httpFieldsPutName, httpFieldsPutTwo) — the date alone; the header model is docs/security/http2.md's
std/net/websocket.ts WsDecoder (feed, next, reset), websocketWriteFrame, websocketFrame, websocketRequestKey, websocketUpgradeResponse, the allocation-free WsAcceptKey, websocketRequestKeyField and websocketWriteUpgradeResponse they are built on, websocketClosePayload, websocketIsUtf8; the handshake's websocketAcceptKey, websocketKeyIsValid, websocketOfferedProtocols, websocketOriginAllowed (with websocketSpanFolds); the client's websocketClientKey, websocketUpgradeRequest, WsHandshake, websocketCheckResponse and their helpers (websocketSpanIs, websocketListInto, websocketListHas)

Out of scope: TLS (docs/security/tls.md, whose TLS-3 and TLS-4 the TLS carrier inherits), nish:net, and nish/crypto/sha1, which only computes the accept key. The external suites — curl, the Autobahn suite's server cases — run in S2's interop job against the serve mode of tests/link/net_http1_server, not here.

Threat model

The attacker is the client: every byte is theirs, split anywhere, and they may pipeline requests, stop reading, send a body slowly or never, upgrade and send frames in any order, and hold the connection open.

A win is a panic, memory or time a client can make the server spend without bound, a request the program sees that a different HTTP/1.1 parser would frame differently (the shapes that smuggle a second request past an intermediary), a response split by a caller's string, or a response sent to the wrong request. The program driving the connection is trusted; its mistakes panic or are refused, and what it writes is checked so that its strings cannot end a line.

As a WebSocket client (websocketUpgradeRequest, websocketCheckResponse) the attacker is the server, or whoever stands between it and a client over plain TCP: every byte of the answer is theirs. They may answer with another status (a redirect, a 200 with a body), with HTTP/1.0, without Upgrade or Connection, with a forged Sec-WebSocket-Accept or one for another key, with an extension or a subprotocol the client never offered, or with frame bytes glued to the head.

A win is a panic, a connection the client takes for a WebSocket that the server did not accept for its key, a protocol or extension it did not ask for, or frame bytes read as HTTP (or HTTP as frames). The client's randomness is the program's: the module draws none, and takes the nonce and every mask key from the caller.

Findings

Id Severity Where Description Disposition
H1-1 Medium std/net/http1-server.ts (Http1Server.expire, Http1TlsServer.expire, Http1Connection.idle; the fix in Http1Connection.headArrived, headAwaited, headLate, expired, nextRequest, Http1Server.readable and Http1TlsServer.readable, written against main at 804120e) The idle timeout counts from the last byte moved, so a client that sends one byte of its head every idleTimeout (slowloris) keeps its slot for as long as it likes, and with every slot held new connections are shed (H1_POOL_FULL). Memory stays bounded: the head is capped by maxHeaderBytes, the slots by the pool. Fixed. Http1Config.headTimeout (30 s by default, checked at start-up beside idleTimeout, which refuses 0 or less) is a deadline for a whole head, counted from the clock the carrier reads when the head's first bytes arrive and cleared only when the head is read whole (nextRequest) or the slot is restarted, so neither a trickle nor bare CRLFs restart it. expire(now) closes a slot that is idle or whose head is past its deadline (expired), on both carriers. The plain carrier starts the clock when a read leaves head bytes in the parser (headArrived). The TLS carrier starts it on any ciphertext once the handshake is done (headAwaited in readable), since a record trickled a byte at a time hands over no plaintext until it is whole; so a TLS client that finishes its handshake and then sends nothing is closed after headTimeout, too. A head pipelined behind an open exchange waits without a clock only while that exchange is open: its clock starts when the exchange ends (nextRequest). Tests: a head still unfinished past headTimeout closes its slot, though the slot is not idle, and its client sees the end, while the kept-alive client's slot stays open, a second piece of a head leaves its clock where the first piece started it, a head finished in pieces within headTimeout is answered, and the pipelined head, still unfinished past headTimeout, closes the slot, a TLS head still unfinished past headTimeout closes its slot, a TLS record still unfinished past headTimeout closes its slot, though it has handed over no plaintext in tests/link/net_http1_server and _f64 (run as link/net_http1_server: exits with 0 and stdout matches expected.out and its _f64 twin), and tests/link/net_http1_server_bad_head_timeout; the first two fail on the base, and the pipelined one and the TLS record one fail on a clock started only where plaintext is read. An alert or close_notify after the handshake starts the clock too, harmlessly, since the slot closes on it anyway; so does a post-handshake message such as a KeyUpdate on a kept-alive slot, which then has headTimeout rather than idleTimeout to send its next head, a shorter wait only where headTimeout is set below idleTimeout. What it does not bound: a body sent slowly (the idle timeout still restarts on each of its bytes; nish/net/handler bounds it with bodyTimeout, HANDLER-5 in docs/security/handler.md), and the TLS handshake itself, which idleTimeout alone bounds (TLS-4).
H1-2 Low std/net/http1-server.ts (fail, the carriers' close; the fix in Http1Connection.lingerStart, drained, lingerLate, expired, and Http1Server.flush and drain) After a refusal the response is sent and the socket closed at once, without the lingering close RFC 9112 §9.6 describes. A client still sending a body when the socket closes may get a TCP reset that discards the error response before it reads it. Nothing is accepted that should not be: the effect is a client that sees a reset instead of a 413 or 400. Fixed. Once a refusal (H1_ERROR) is sent on a slot whose client has not ended its stream, Http1Server shuts its write side (netShutdown) and reads and throws away what the client still sends, until the client hangs up, Http1Config.lingerBytes (64 KiB by default; 0 closes at once, as before) have been drained, or expire(now) finds the slot past Http1Config.lingerTimeout (2 s by default). Both are checked at start-up. The drained bytes never reach the program and do not move the idle clock, so the linger is bounded by its own deadline, not idleTimeout; next answers H1_NEED_MORE for the slot meanwhile. Only expire ends a linger at lingerTimeout: flush and next do not read the deadline, so a program that never calls expire keeps a slot lingering until its client hangs up or sends lingerBytes. A lingering slot is busy: it counts against the pool for up to lingerTimeout after its refusal, the price of a client that reads its error. Only a refusal lingers (fail, and a WebSocket close for an error, both H1_S_FAILED); a socket that fails is aborted and closed at once, never lingered. Over TLS, Http1TlsServer's carrier already lingered after every close (TLS-6 in tls.md). Tests: and the slot lingers, draining what it still sends, past lingerTimeout, before headTimeout and idleTimeout, it is closed, a refused client that floods the linger reads its 505 first, past lingerBytes it is closed whatever it still sends, a refused client that hangs up ends the linger at once in tests/link/net_http1_server and _f64, and tests/link/net_http1_server_bad_linger and _bad_linger_bytes; the lingering ones fail with lingerBytes 0, which closes at once as the base did.
H1-3 Low std/net/http1-server.ts (acceptWebSocket), through std/net/websocket.ts (websocketRequestKey, websocketUpgradeResponse), written against main at 05c92f49 Accepting a WebSocket left bytes in the arena (the key and the accept key as strings, the SHA-1 schedule and digest, the 101 as an array: 992 bytes an accept at 05c92f49) until the program reset it. It was once a connection, not once a message, and bounded by the connection rate the pool allows — the shape of TLS-3 at a smaller size. Fixed. acceptWebSocket finds the key's field with websocketRequestKeyField, hashes it with a WsAcceptKey the slot builds on its first accept and keeps (a Sha1 from nish/crypto/sha1 whose schedule and padding block are its own, and base64StdPadEncodeInto from nish/crypto/base64url, which writes into a caller's buffer), and writes the 101 straight into the connection's output with websocketWriteUpgradeResponse. A slot's later accepts allocate nothing, as HpackDecoder does for H2-1. The chosen protocol is now checked as an RFC 9110 token, as the doc already said, where it was checked only as field text. Tests: H1-3: and none of them moves the arena in tests/link/net_http1_server and _f64 (run as link/net_http1_server: exits with 0 and stdout matches expected.out and its _f64 twin) fails on the base and passes here; H1-3: a thousand WebSocket accepts after a slot's first each answer the same 101 with RFC 6455's accept key passes on both. websocketWriteUpgradeResponse writes the bytes websocketUpgradeResponse answers, and a reused WsAcceptKey takes the §1.3 key again and the HTTP1_NO_ROOM and HTTP1_REFUSED checks in tests/link/net_websocket and _f64 pin the pieces.
H1-4 Low std/net/http1-server.ts (Http1Connection.expiresNoSooner, read by Http1Server.expire and Http1TlsServer.expire) expire walks every slot only when the soonest one can be due, but that bound counted a head clock not yet started from the slot's last move, so a kept-alive slot quiet for longer than headTimeout (30 s by default) put it in the past and every expire walked every slot. Clients that hold quiet keep-alives, a few hundred of 30,000 in a benchmark with 7 s think times, made the work of each turn of the loop grow with the number of connections: about a third of a server's CPU there. Nothing is closed that should not be. Fixed. expiresNoSooner(now) counts a head clock not yet started from now, since one started later starts no sooner, and keeps lastActive + idleTimeout and a started clock's headSince + headTimeout. While an exchange is open it counts from lastActive, since nextRequest starts a pipelined head's clock there when the exchange ends, which can be before now; a slot quiet past headTimeout with its exchange still open (a slow handler) still makes expire walk every slot, which is rare and no worse than the base. Tests: a kept-alive slot quiet past headTimeout is due no sooner than later and a head pipelined behind an open exchange is due no later than its bound says in tests/link/net_http1_server and _f64; the base cannot build the first (expiresNoSooner took no now) and its bound there is past, and the second fails on a clock not yet started counted from now alone.
H1-5 Medium std/net/http1-codec.ts (Http1Parser.next, resting, http1StartRequest, the field headHeld), read through std/net/http1-server.ts (Http1Connection.respond, acceptEncoding, respondEncoded) On a kept-alive request the parser reset its head (method, target, version, fields, keep-alive) as it reported HTTP1_END, before the program had answered. A response written at H1_END was framed from the reset head: a HEAD request was answered with a body, which a client or a proxy sharing the connection reads as the start of the next response, and an HTTP/1.0 keep-alive client was answered with chunked framing it cannot read, since the reset version was 1.1. acceptEncoding() and targetIs read nothing there either. Fixed (option 1: keep the head, copy nothing). At the keep-alive HTTP1_END the parser moves to the request line but holds the head (headHeld); the next next() resets it before it reads any byte of the next request. The server calls next() again only once the response is done (nextRequest), so the head stays this request's for its whole response whatever pipelined bytes are fed behind it, and nothing is copied or allocated. resting() is false while a head is held, so a slot is not taken for idle with a request still unanswered. Tests: every line of tests/link/std_http1_end_head (run as link/std_http1_end_head: exits with 0 and stdout matches expected.out); against the base std, 14 of its 49 checks fail, among them HEAD: no body is owed, HEAD: the output is the head alone, HTTP/1.0: not chunked, pipelined: acceptEncoding at H1_END is the first's gzip, fed after: the held head is still the first's (the next request's bytes fed after H1_END, enough to grow the input buffer) and router: at H1_END the first's route, not a 404.
H1-6 Low std/net/websocket.ts (websocketFrameEvent, websocketUnmaskInto, the field WsDecoder.frameChecked) A text frame's payload was checked as UTF-8 only once the whole frame had arrived, so a peer could send a byte that can never be valid UTF-8 and then keep the connection, and up to maxMessage bytes of buffer, for as long as it took to send the rest. RFC 6455 §8.1 asks for the connection to be failed as soon as the bytes so far cannot be a valid prefix. Autobahn's 6.4.3 and 6.4.4 grade the late 1007 NON-STRICT. Nothing invalid was ever handed out; the 1007 was only late. Fixed. A text frame, or a continuation of a text message, is unmasked and checked as its bytes arrive. frameChecked records how far the current frame has been checked, so each byte is unmasked and checked once, and the key is rotated to that offset (websocketUnmaskInto's phase). A bad byte answers WS_ERROR with 1007 while the rest of its frame is still owed. Binary frames are unchanged. Tests: refused with 1007 inside a frame still arriving, refused with 1007 inside a masked frame still arriving and refused with 1007 inside a continuation still arriving in tests/link/net_websocket and _f64 (run as link/net_websocket: exits with 0 and stdout matches expected.out and its _f64 twin) fail on the base, which answered WS_NEED_MORE; a valid prefix of a frame still arriving is not refused, masked text fed a byte at a time, masked text fragments fed a byte at a time, a four-byte character fed a byte at a time and a four-byte character across the buffer's growth, fed a byte at a time pass on both. The message buffer grows with the bytes that have arrived, never to the length a header declares: a 65536-byte text frame with one byte arrived holds a small buffer pins it. The interop job's autobahn run checks it against an independent client.
H1-7 Low std/net/http1-server.ts (Http1Connection.sameHead, http1ServerKept) The kept-head compare stops at the first byte that differs, so how long respond takes can tell whether a response's head equals the one before it on the same connection. Both heads are the same program's answers to the same peer, and nothing is kept across connections or slots (restart empties the kept head's record). Open, accepted. Not attacker-relevant: the peer learns at most whether its own two responses share a head, which their bytes already show it. A program that puts a secret in a header and wants no timing signal at all writes it in the body.
H1-8 Medium std/net/http1-codec.ts (http1ChunkSize; the fix in http1ChunkExtValid, http1QuotedStringEnd, http1SkipOws, written against main at 187336a) A chunk-size line's extension was checked only for control bytes: anything after the ; up to the CRLF was skipped. RFC 9112 §7.1.1 gives the extension a grammar (*( BWS ";" BWS name [ BWS "=" BWS value ] ), the name a token, the value a token or a quoted-string), and a front end that follows it reads a quoted-string to its closing quote, across the line's end, where this parser stopped at the CRLF. The two then frame the body differently, which smuggles a request inside a chunk extension (the class of CVE-2026-2332 and CVE-2026-33870). Fixed. http1ChunkSize parses the whole extension with http1ChunkExtValid and refuses one that does not match the grammar with 400 ("a malformed chunk extension"): an empty name or value, a second ;, whitespace not followed by ; or =, a value that is neither a token nor a quoted-string, bytes after a quoted value, a quoted-string that does not close before the CRLF, and a backslash not followed by a value byte. The extensions themselves are still not handed to the program. Tests: a chunk extension with no name, a chunk extension that is a second semicolon, a chunk extension name with a space in it, a chunk extension with an empty value, a chunk extension followed by whitespace alone, a chunk extension value that is not a token, a chunk extension with bytes after its quoted value, an unclosed quoted chunk extension and a quoted chunk extension whose closing quote is escaped (each printed as refused with 400: …), and a quoted chunk extension that runs across lines hides no second request in tests/link/net_http1 and _f64 fail on the base (which read a second head, GET /hidden, from inside the first request's chunk extension); a chunk extension name=value is read, a quoted chunk extension with BWS, a semicolon and an escaped quote is read and two chunk extensions, the first with no value, are read pass on both. tests/link/net_http1_parse_diff's frozen reference has the same rule mirrored into it by hand, read through http1ChunkExtValid, so the differential test still compares everything else. The client's parser had the same gap: HC-2 in http1-client-codec.md.
H1-9 Low std/net/http1-codec.ts (http1EndOfHead, the parser's hostField; the check in std/net/url.ts's urlIsHostPort, urlHostEnd, urlPortOf, written against main at 187336a) The Host field was counted (exactly one in HTTP/1.1, at most one in HTTP/1.0) but its value was never read: Host: a b, Host: u@h, Host: h/p, Host: a, b and Host: h:99999 were all handed to the program. RFC 9112 §3.2 makes the value uri-host [ ":" port ] and has a server answer 400 to anything else. A program that builds a URL, an origin or a virtual-host lookup from it sees a host no URL parser would give it, and a proxy behind it may read another host from the same bytes. Fixed. http1EndOfHead reads the one Host value with urlIsHostPort, the authority rules urlParse already applied (a bracketed IPv6 literal, a dotted IPv4 address, or a reg-name of unreserved bytes; a port of digits up to 65535), and refuses anything else with 400 ("a Host that is not a host and port"). An empty Host is still read, as RFC 9112 §3.2 allows when the target has no authority. The reg-name is narrower than RFC 3986 (no percent-encoding, no sub-delims): no DNS name needs them. Tests: a Host with a space in it, a Host with userinfo, a Host with a path, a Host that is a list, a Host whose port is not digits, a Host whose port is past 65535, a Host with an unclosed IPv6 bracket, a Host that reads as a number but is no IPv4 address and an HTTP/1.0 Host with a space in it (each printed as refused with 400: …) in tests/link/net_http1 and _f64 fail on the base; a Host with a port is read, an IPv6 Host with a port is read, an IPv4 Host is read and an empty Host is read, as before pass on both. urlReadAuthority now reads its host and port through the same two helpers, so the URL parser and the server agree on what a host is (net_url* unchanged). tests/link/net_http1_parse_diff's frozen reference has the check mirrored into it by hand; both parsers still agree on every case, and the summary it pins moves by the requests now refused (2,309 more 400s).
H1-10 Low std/net/websocket.ts, std/net/http1-server.ts (Http1Connection.acceptWebSocket; the check in websocketOriginAllowed, websocketSpanFolds, written against main at 187336a) Neither side of the server's opening handshake read Origin, and nothing offered a program a way to. A browser sends the user's cookies with a WebSocket handshake that a page on another site opens, and the page reads what comes back, so a WebSocket that trusts those cookies served any site that asked (cross-site WebSocket hijacking, RFC 6455 §10.2; the class of CVE-2026-22689). Fixed, as an opt-in check. websocketOriginAllowed(parser, allowed) answers true only when the request carries exactly one Origin and its value is one of allowed, compared whole in any ASCII case, allocating nothing; a program calls it before acceptWebSocket and answers 403 when it is false. acceptWebSocket itself still does not read Origin: a client that is not a browser need not send one, so refusing a handshake without it would break those clients, and which origins are the program's own only the program knows. The module doc and the guide's "Checking Origin" section show the check. Tests: origin: an allowed origin is accepted, origin: the second allowed origin, with its port, is accepted, origin: compared in any ASCII case, on either side, and refused origin: another site, an allowed origin as a prefix, an allowed origin's suffix, the other scheme, another port, none sent, two Origin fields, the first allowed, an opaque origin not listed, an empty allowed list in tests/link/net_websocket and _f64; the guide's example compiles under node tests/run.js guide.

Fuzzing

Fuzzed by tests/fuzz/targets/http1.ts, tests/fuzz/targets/websocket.ts, tests/fuzz/targets/websocket-client.ts.

Target What it drives Executions
http1 the HTTP/1.1 parser fed in pieces under small or default limits, chunked bodies, an upgrade declined or taken, checking every refusal is a 4xx or 5xx 57,537,869
websocket the WebSocket frame reader with masking required or not and a message cap of 0, 16, 125 or 65,536 bytes, checking text is UTF-8, every frame round-trips through websocketFrame, and pong and close payloads 117,903,219
websocket-client a server's answer to the client's upgrade, offering none, either or both of chat and superchat, fed whole or in pieces of 1 to 255 bytes through Http1ResponseParser told to expect the upgrade, then websocketCheckResponse and a client's WsDecoder over the bytes past the head; checking that only a 101 to HTTP/1.1 is accepted, that its accept never matches another key, that its protocol is one offered, and that text frames are UTF-8 not yet run

websocket-client has not run under libFuzzer: the session that wrote it had no libclang-rt. Its 18 seeds in tests/fuzz/corpus/websocket-client/ (an accepted 101 with and without a protocol and with a frame glued on, and each refusal, a missing Sec-WebSocket-Accept among them) were replayed through fuzzOne linked natively against tests/fuzz/harness.c, with 4,000 mutations of them besides, without a crash; its 31-minute run is owed with the next fuzzing pass.

The other targets each ran for 31 minutes (1,861 s, one core each, four at a time) on commit b52b765, starting from its seed corpus in tests/fuzz/corpus/<target>/, with libFuzzer's -timeout=1 -rss_limit_mb=2048; every panic, sanitizer report, timeout and OOM counts as a finding. None found: no crash, timeout or OOM (a target's own contract check fails by panicking, so it counts too). The libFuzzer harness these targets build against lands with the harness stage of #888; a new finding adds a row to Findings above, with its input kept as a regression and a link check that replays it.

Properties verified

Each property below is pinned by a test that fails if it stops holding.

Cut anywhere, framed the same (tests/link/net_http1, _f64): a corpus of pipelined keep-alive requests, both body framings, an upgrade and the smuggling shapes, fed whole, cut in two at every byte and fed a byte at a time, gives the same transcript every way — by a parser that keeps the head as text and by one that keeps only spans (keepText off, the server's), whose heads must describe the same request byte for byte. Over loopback (tests/link/net_http1_server, _f64) a chunked POST with an extension cut at every byte, and sent a byte at a time, is echoed whole every time.

Request smuggling refused (net_http1 for the parser, net_http1_server through the server): Content-Length with Transfer-Encoding (RFC 9112 §6.1), two Content-Length fields, conflicting or not, one that is not a run of digits, Transfer-Encoding in HTTP/1.0 or not ending in chunked, an obs-fold, a bare LF, whitespace before a colon, a malformed chunk size, chunk extension (H1-8) or chunk terminator, a Host that is not a host and port (H1-9) — each a 400, never a guess.

Through the server each is answered with its status, Content-Length: 0 and Connection: close, and the connection ends: 400 (a chunk size that is not hex, both length fields, two lengths that disagree, an obs-fold, a missing Host), 413 (a body past maxBody), 414 (a target past maxTarget), 431 (a header section past maxHeaderBytes), 501 (a coding other than chunked), 505 (HTTP/2.0 in a request line). A refusal after a good pipelined request answers the good one first. A refusal once a response has started (a bad chunk size in a body the program is echoing) sends no second response and ends the connection.

A control byte in a field value is refused wherever it falls (net_http1, _f64): the scan for a line's end (http1TakeLine) loads sixteen bytes at a time as a u8x16 and flags each lane below 32 or equal to 127, bitmask(or(lt(v, 32), eq(v, 127))). Each lane is compared on its own, so the mask is exactly the control bytes and DEL of the block, with no carry between lanes; the scan moves to the lowest set bit, the first such byte, and a block with none is skipped whole. A vector is loaded only while sixteen bytes are left before both the end of what has arrived and buf's length, so it never reads a byte the peer has not sent or past the buffer; the tail shorter than a vector, and the bytes after a control byte, are read one at a time with the same predicate. It is also the check of the value: a control byte other than HTAB, or DEL, on a field line is a 400, with no second pass over the value.

NUL, 0x01, 0x1f, DEL and a bare CR placed at each of the forty bytes of a long value are each refused, and HTAB and an obs-text byte at each of them are read. At the block boundaries the stream is also cut at every byte, so a CR that ends what has arrived so far is read again with the byte after it, never taken as a line end or a refusal on its own.

The request target is visible ASCII, checked sixteen bytes at a time (net_http1_server, net_http1_parse_diff, 2026-11-08). http1RequestLine loads the target as u8x16 blocks and flags each lane outside 33 to 126 with gt(subWrapping(v, 33), 93): the unsigned wrap sends 0 to 32 to 223 to 255 and 127 to 255 to 94 to 222, all above 93, and 33 to 126 to 0 to 93, so the mask is exactly the bytes the scalar loop refuses, SP among them. The scan stops at the lowest set bit. The line has already been taken, so the byte at lineEnd is its CR, which the predicate flags: a block may load bytes past the line's end, all inside buf, but the scan stops at that CR or before it, so no byte of the next line is ever taken as target. A vector is loaded only while sixteen bytes are left in buf, the index is clamped to lineEnd after the vector loop, and the tail goes a byte at a time. Whatever stops the scan, the byte there must be the SP before the version or the line is a 400 (414 first if the target is past maxTarget), as before. net_http1_server refuses, counting from the target's first byte, a DEL on the second block's first lane, a byte above 126 on its second, and a tab on its sixth; net_http1_parse_diff covers every lane and the tail.

A faster parser gives the same answers (tests/link/net_http1_parse_diff, 2026-11-03). The parser's speed work (the line scan that jumps to its control byte, CRLF taken in one step, the branch-free token check, a field name lowercased while it is scanned in head) is checked against main's parser frozen beside it in old.ts: both are fed the same bytes in the same pieces, and after every event they must agree on the event, the status and reason, and everything a caller can read.

The default run, seed 1175, is 464,424 cases (the fuzz corpus and its regressions cut every way, every byte at every position of three requests, nine inserted bytes at every position, each limit at -1, 0 and +1, the name, value, tight-limit and browser-head cases below, and 100,000 grammar requests) and 4,129,500 events, among them 310,737 refusals, in about 8 s of the test's --profile speed build; it must print the summary in expected.out (counts as of 2026-11-12).

A header section of maxHeaderBytes - 1 or maxHeaderBytes bytes, empty line included, as one field or two, reads a head, and one more byte is a 431. A soak of seeds 1 to 4 at 250,000 grammar requests each (577,992 cases a seed, 2,311,968 in all, on 2026-11-12) agreed. The test sees a one-lane error in either vector scan (checked 2026-11-08): taking the byte after the first set bit in the line scan (32 - for 31 -) fails the default run at case 19 (a 400 for "a malformed HTTP version" where main reads the head), the same in the target scan fails it at case 1 (a 400 for "a malformed request target"), and letting DEL into the target (94 for 93) fails it at case 16,366, where main refuses GET \x7fa and the mutant reads a head. No limit, status or reason string changed.

The version check reads the eight bytes HTTP/d.d as one 16-byte load where at least 16 bytes of buf remain, and byte by byte in the tail; a field line that starts with whitespace (obs-fold) is told apart only once its name has failed, since whitespace is no tchar and such a line's name is empty. Both keep main's status and reason. The test sees a lost lane in the vector version check (checked 2026-11-12): dropping the . lane from its mask (31 for 95) fails the default run at case 18,543, where main refuses HTTP/1\x001 as "a malformed HTTP version" and the mutant reads a head.

One exchange at a time, in order (net_http1_server): pipelined requests are answered in the order they came, because the next head is not read until the current response has ended and the current body has been read to its end; a pipelined pair and a refusal behind a good request pin it. Pipelined bytes wait in the parser's buffer, and once inputLimit() of them wait the slot stops asking to be read.

When an exchange ends (net_http1_server_implicit_end): a response with a Content-Length ends once its last byte is written, through write or sendBody, and one with no body (Content-Length: 0, HEAD, 204, 304) once its head is, whether or not the program calls end; the connection checks at the boundary, when it would read the next request, so end called before then answers as it always has (0, and the same bytes on the wire). A chunked body, and an unframed one to HTTP/1.0, ends only at end, since the connection has no length to count: one byte short of the length, or chunked without end, and the next request is neither read nor answered, and no last chunk goes out. A program that forgot end on a length-framed response used to leave a kept-alive client waiting forever with nothing reported.

The head stays the request's until it is answered (std_http1_end_head): at HTTP1_END of a kept-alive request with the next one already fed behind it, the parser still reports the first request's method, target, fields, version and keep-alive, and is not resting; the next next() reads the second whole. Through the server, acceptEncoding() and targetIs at H1_END are the first request's, a HEAD answered there gets no body, and an HTTP/1.0 keep-alive request answered there is not sent chunked (H1-5).

Streaming both ways, bounded (net_http1_server): a 2 MiB body with a length and three hundred chunks in are echoed through a 4 KiB chunk and an 8 KiB output, and no H1_BODY hands over more than chunkSize; a 2 MiB chunked response goes out as the socket drains.

A write the output cannot take answers what it took, the connection reads nothing until half the output is free (so the window the program writes from stays valid), and H1_WRITE says when to go on. The sans-IO checks drive each held-back path: a head, a chunk, the last chunk and a frame that do not fit, and the room each waits for.

A body sent from the caller's bytes is write's, on the wire and in its answers (net_http1_server_send_body): sendBody gathers the queued output and a Content-Length body into one netWrite2 and copies only what the socket did not take, through write, so the same back-pressure holds: under a 4 KiB send buffer it answers short, a second call behind the held write answers H1_AGAIN, and H1_WRITE says when to go on. It keeps no reference to the caller's buffer once it returns, and only reads it: sendBody and write take a readonly u8[], and a read-only body is sent whole and through the chunked fallback alike.

Every exchange is run through write and through sendBody, and the client reads the same bytes: a 3,000-byte body, a 4 MiB one under the small send buffer, a response pipelined behind one already queued (sent in order, in the same call), and the fallbacks, which copy as write does — chunked, HEAD, a 204, a socket that would block before anything goes, and a connection with no socket of its own (sans-IO, and Http1TlsServer, whose output is TLS records; fd is -1 there, so a socket number is never written to past restart or abort).

A body past the length, or one after respondEncoded has finished the response, is refused as write refuses it. A send that fails other than by blocking (the peer reset the connection) aborts the connection and answers H1_CLOSED.

What the program writes is checked (net_http1, net_http1_server): a status outside 100 to 599, 101 through respond, a field the server decides (Connection, Upgrade, Keep-Alive, Transfer-Encoding, Content-Length), a name that is not a token, a CR, LF or other control character in a value or the reason, no body on a response that needs one, a head larger than the output, a second response, more body than the length, end while the length is owed — each H1_INVALID or H1_CLOSED, and nothing is written.

http1WriteResponseHead counts the whole head before it writes a byte, so HTTP1_NO_ROOM and HTTP1_REFUSED leave the buffer untouched. A response to HEAD, a 204 and a 304 carry no body whatever the program writes; a chunked response to HTTP/1.0 goes unframed and ends with the connection.

One Date, from one clock read a second (net_http_date, _f64; net_http1, net_http1_server and their _f64 twins; written against main at 249cbe9, cited by function rather than by line). Every final response, an error included, carries a Date (RFC 9110 §6.6.1) and a 1xx carries none; a program's own date field, in any case, is sent instead of the server's, so a response never carries two.

Two date fields of the program's own, in any case, were sent as they came until #696: Date is a singleton (RFC 9110 §5.3) whose value holds a comma, so a reader cannot combine the two or tell which to believe. http1WriteResponseHead now answers HTTP1_REFUSED for a second one, writing nothing, and http1ResponseHead answers null (net_http_date, _f64; before: the head went out with both).

On a final status http1WriteResponseHead refuses a date that is not field text, so the date cannot split the head (a 1xx never sends it, so there it is not read), and counts its 37 bytes before it writes, so HTTP1_NO_ROOM still leaves the buffer untouched. The largest head fail writes — 431's status line, the date, Content-Length: 0 and Connection: close — is 123 bytes, inside the 256 kept for what the connection writes itself.

httpDateWrite agrees with a calendar counted a day at a time on every day from 1970 to 2399 and refuses, writing nothing, a second it cannot name in four digits or a buffer without the room. HttpDate formats once a second however often it is read, in either direction of a clock step, with Arena.used() flat; a pool's slots share one.

Tests: link/net_http_date: exits with 0 and stdout matches expected.out, link/net_http_date_f64: exits with 0 and stdout matches expected.out, link/net_http1: exits with 0 and stdout matches expected.out, link/net_http1_f64: exits with 0 and stdout matches expected.out, link/net_http1_server: exits with 0 and stdout matches expected.out, link/net_http1_server_f64: exits with 0 and stdout matches expected.out — each the template link/${name}: exits with ${wantCode} and stdout matches expected.out in tests/run.js.

A faster head writer writes the same bytes (net_http1, _f64, 2026-11-04, written against main at 1d92417e). http1WriteResponseHead checks each field value and the date sixteen bytes at a time (http1BytesAreFieldText, http1LanesAreFieldText): a lane below 32 that is not HTAB, or DEL, refuses, exactly http1IsValueByte, and the last vector ends at the last byte, overlapping the one before it; under sixteen bytes it is checked a byte at a time.

It writes the status line and the Date: , Content-Length: and Connection: names as one sixteen-byte store each (http1PutStatusLine, http1PutFixed), only where at + 16 stays inside the head it has already counted (need), whose every byte from there on is written after, so the lanes past the text are overwritten and no byte past the head is touched; anywhere else they are written a byte at a time, as before.

http1PutText, which the head writer, http1WriteLastChunk and other callers share, tests once that the whole text fits (0 <= at <= out.length - text.length) and then copies it with no check in the loop; a text that does not fit takes the old loop, which writes the bytes that land inside out and none outside, and both answer at + text.length. Nothing it accepts or refuses changes.

Tests: the smallest head is 17 bytes, and the bytes after it are untouched, it fits a buffer of 17, and not one of 16, a head with every fixed field, at an offset, leaves the bytes either side of it alone, and fits a buffer exactly its size, and not one a byte shorter, each status digit and a long length land in place, and, for values of 1, 15, 16, 17, 31, 32 and 33 bytes, a <n>-byte value of text, HTAB and obs-text is written and refused: byte <b> at <k> of a <n>-byte value for NUL, LF, CR, 0x1f and DEL at the first byte, bytes 14, 15, 16, 17, 20, 25 and 29 (the bytes the last vector shares with the one before, in a 31- or 33-byte value) and the last two, each place once, and refused: an LF at <k> of a 29-byte date at bytes 16, 20 and 28, and a text past the end still answers at + length, and writes only the bytes inside the buffer and their before-the-start twins for http1PutText, in tests/link/net_http1 and _f64 (link/net_http1: exits with 0 and stdout matches expected.out).

A field name read sixteen bytes at a time is read the same (net_http1, _f64, net_http1_parse_diff, 2026-11-04, written against main at 4dc09dcc). A kept field line is copied into the held head as before, and http1LowerName then reads the copy's name a vector at a time: http1NonTokenLanes marks each lane outside 33 to 126 or among the seventeen delimiters, exactly the bytes http1IsTokenByte refuses, and the name ends at the lowest marked lane or at the line's end, whichever is first.

Only the upper-case letters below that point are lowered; the vector is stored back with every other lane as it was read, so the colon, the value and the held head's bytes past the line (stale bytes of an earlier request included) are unchanged.

Loads and stores stay inside head: the vector runs only where k <= head.length - 16, and the last bytes before the buffer's end are read a byte at a time by the old loop. The method and a trailer's names keep the byte test. Nothing accepted or refused changes, and no limit, status or reason string moved. Tests: a <n>-byte name is lowered and its value kept, '@' at each of a <n>-byte name's places is a 400 and a <n>-byte name that ends its line is a 400 for names of 15, 16, 17, 31, 32 and 33 bytes, and a name byte of 128 is a 400, in tests/link/net_http1 and _f64; in net_http1_parse_diff, 46,867 name cases against main's parser: every length 1 to 40 in lower, upper and mixed case, whole and a byte at a time (the edge lengths also at every two-feed split); 25 bytes that end or refuse a name (all seventeen RFC 9110 delimiters, NUL, HTAB, LF, CR, SP, DEL, 0x80 and 0xff) at every place of every length; names of 15, 16, 17, 31, 32 and 33 bytes after an X: line of 170 to 240 bytes, which puts the name's end on, before and after the held head's last byte; and a short name read over a head an earlier request's upper-case lines filled. The default run is now 237,143 cases (expected.out).

A head read section-wide, its framing fields classified as read (net_http1, _f64, net_http1_parse_diff, 2026-11-12, written against main at b49794d8). The header section's lines are found and parsed in one loop (http1Section) that keeps the control-byte mask of the last vector loaded, so a line after a short one is not loaded again; the line's control flag is the value check, as before.

The head's layout changed. It holds the request line (method to version, no CRLF), copied by http1HeadAppend, and then the header section's lines with their CRLFs: the section scan stores each vector it loads into the head at the same offset from the section's start (buf[x] at head[x + delta]), so a field line is in the head before it is parsed, and a line that ends in a later read finds its first bytes, copied provisionally past headLength, where the earlier call left them. http1HeadGrow keeps every byte of the old array, those provisional bytes included, not only the first headLength. No copy starts at or past copyStop, the line's start plus what is left of maxHeaderBytes plus 2 (the line's CRLF), and a line reaching it is a 431 before its value is read, so a section's copy ends within one vector of maxHeaderBytes + 2 bytes past the request line, whatever the peer sends. Every store is a bounds-checked u8x16 store or copyBytes; the head is grown first whenever a store would come within 32 bytes of its end. So headLength is the old head's length plus two bytes for each kept field line and two for the closing CRLF, and with those CRLFs taken out the head is main's byte for byte; net_http1_parse_diff pins both, and that each CRLF ends where the next field's name span starts (mixHead). A line whose CR is the last byte a vector or the byte-at-a-time tail copies has its LF stored when the line is taken, so no stale byte from an earlier request is left between a CR and the next line. http1HeadAppend relies on its caller having called http1HeadGrow when the request line would leave fewer than sixteen bytes of slack; without that it copies nothing (both of its paths check the bounds) and the spans would read stale bytes, never bytes outside the array.

Every kept field's lowered name is then classified (http1FramingField) as Host, Content-Length, Transfer-Encoding, Connection, Upgrade or none, and the counts, the Content-Length field's index and the Connection options are kept as the line is read. http1EndOfHead applies RFC 9112 §6.3's framing rules to those counts exactly as it applied them to its own walk over every field: one Host on HTTP/1.1, Content-Length and Transfer-Encoding together refused, two Content-Lengths refused, a coding list that must end in a single chunked. A field is classified by its whole name, in any case, whatever its position, length or value, so a request cannot place a framing field where the classification misses it. There is no branch on the target, on a known header set or on the length of the head.

The response writer (http1WriteResponseHead) is unchanged from b49794d8. Nothing accepted or refused changes, and no limit, status or reason string moved.

Tests: in net_http1_parse_diff, 204,523 value cases against main's parser: a Cookie and an Authorization value and a target of every length 1 to 48 and of 255, 256, 257, 1000 and 4000 bytes, with CR, LF, NUL, HTAB, SP, 0x1f, DEL, 0x7e, a comma, 0x80 or 0xff at every place in the first and last 48 bytes, each value in both fields under five setups (text kept, spans only, fresh arrays, a declined upgrade, and pieces of 13, 16 and 3 bytes in turn); the same heads whole and cut at every two-feed split at the edge lengths; and a head of 60 fields cut every way. 19,920 tight-limit cases set maxTarget, maxHeaderBytes and maxHeaders to sixteen values in a row at -1, 0 and +1, so the byte that decides between a head and a 414 or 431 falls in every lane, each whole, a byte at a time and split at every point. 2,838 cases split a 936-byte browser head, alone and pipelined after a short GET, at every point.

Mutations tried against the default run, each a one-line change to http1-codec.ts, built and run on 2026-11-12:

Mutation Result
The section scan's mask drops lane 16 (& 32767) fails at case 33,582: "a control character in a field value" where main reads a bare LF
The carried mask is dropped after each line (bits = 0) fails at case 2: "a malformed field name" where main reads the head
http1HeadGrow keeps only headLength bytes, losing the provisional copy fails at case 88,755: "a malformed field name" where main reads the head
The section scan never grows the head before a store panics, "index out of range: 269 >= 256": the store's bounds check holds
copyStop one byte short of the line's value (- 1 for + 2) panics on an i32 overflow check
copyStop without the CRLF's two bytes (+ 0 or + 1 for + 2) survives: the CR and LF of the line at the limit are copied but never read
No LF stored when a line is taken (the head before this fix) fails at case 24, a chunked POST cut after 21 bytes: the last field line's CR is the last lane of a vector, and the head holds a stale byte where its LF belongs
The grow threshold at 16 bytes from the end, not 32 survives: a store needs 16, so this only grows later

Connection management (net_http1_server): Connection: close in a request is answered with it, and the connection closes; HTTP/1.0 closes unless it asked for keep-alive, which is then answered with Connection: keep-alive; an upgrade the program answers without switching leaves the connection reading HTTP; Expect: 100-continue may be answered with a 100 before the body. A request cut short by the end of the stream ends the connection; a client gone in the middle of a response fails the write and frees the slot.

WebSocket (net_websocket, net_http1_server): the opening handshake is accepted only when websocketRequestKeyField finds one (GET, HTTP/1.1, exactly Upgrade: websocket with Connection: upgrade, version 13, a valid key), and the 101 carries RFC 6455 §1.3's accept key. Bytes sent with the handshake are the first frames.

A ping is answered with its pong and a close with a close of its code (an empty close for none), from 256 bytes of output kept for what the connection writes itself. An unmasked frame is closed with 1002 and a message past maxMessage with 1009, refused from the frame's header. A frame larger than the output, a close through sendFrame and a close code that may not be sent are refused.

WebSocket client (net_websocket, net_http1_client, net_loopback): websocketClientKey makes a key only of a 16-byte nonce (refused client key: a 15-byte nonce, a 17-byte nonce, no nonce; the §1.3 nonce gives the §1.3 key).

websocketUpgradeRequest writes the request through http1UpgradeRequestHead, so its host, target and protocols cannot end a line, and refuses an empty host, an invalid key, and a protocol that is empty, not a token or offered twice (the refused request: … checks: an invalid key, a protocol that is not a token, a protocol holding a comma, an empty protocol, a protocol offered twice, CR LF in the host, an empty host, CR LF in the target, CR LF in a protocol).

websocketCheckResponse checks RFC 6455 §4.1's list in order and answers the first failure: a status other than 101, a redirect included, is WS_HS_STATUS and never followed (refused check 1: a 302 is not followed, a 200); HTTP/1.0 is WS_HS_VERSION (refused check 2: an HTTP/1.0 101); Upgrade missing, twice or not websocket is WS_HS_UPGRADE (refused check 3: no Upgrade, Upgrade: h2c, Upgrade twice); no Connection listing upgrade is WS_HS_CONNECTION (refused check 4: no Connection, Connection without upgrade); an accept missing, twice, forged or for another key is WS_HS_ACCEPT, and an invalid key matches no accept (refused check 5: no Sec-WebSocket-Accept, a forged Sec-WebSocket-Accept, Sec-WebSocket-Accept twice, an accept for another key, an invalid key matches nothing); any Sec-WebSocket-Extensions is WS_HS_EXTENSION, since the client offers none (refused check 6: a Sec-WebSocket-Extensions); and a protocol not offered, a list, the field twice, or one in another case is WS_HS_PROTOCOL (refused check 7: a protocol when none was offered, a protocol that was not offered, a protocol list, Sec-WebSocket-Protocol twice, a protocol in another case).

A 101 is read only by a parser told expectUpgrade (in http1-client-codec.md), so frame bytes glued to the head are handed over by tunnelBytes and read as frames, never as HTTP (glued: the frame past the head is a message, and it says Hello).

Over the loopback, plain and TLS, each connection draws a fresh nonce and every frame a fresh mask from crypto.getRandomValues (websocket: websocketCheckResponse accepts the 101 and its accept for the random key, websocket: the second connection drew a key of its own).

Caps, all fixed at start-up (Http1Config): the request target (maxTarget, 8,192), the header section and each trailer section (maxHeaderBytes, 16,384) and its fields (maxHeaders, 100), a request body (maxBody, 2^30), the most body one H1_BODY hands over and one read takes (chunkSize, 16,384), the output (outputSize, 64 KiB, of which 256 bytes are kept for what the connection writes itself; a pool's slots borrow it from one Http1OutputPool while they write, below), a WebSocket message (maxMessage, 1 MiB), the idle timeout (idleTimeout, 60 s, read by expire) and the deadline for a whole head (headTimeout, 30 s, read by expire; H1-1).

The slots are the pool's size. An Http1Server builds a slot's connection on the first accept into it and keeps it, so it never holds more than size connections, each within the caps above, and holds none it has not needed: a pool of 16,384 takes 16,688 bytes before its first connection (HTTP1_SERVER_START_BYTES, "net_http1_server: a 16,384-slot Http1Server takes at most HTTP1_SERVER_START_BYTES before its first connection"), and the connection past size busy slots is shed with H1_POOL_FULL without one being built. A slot never accepted into answers like a closed one (net_http1_server).

Http1TlsServer does the same over a TlsTcpServer that does it too: a slot's Http1Connection, TlsRecordServer and server random are built on the first accept into it, so a pool of 16,384 takes 58,296 bytes before its first connection (HTTP1_TLS_SERVER_START_BYTES, the templated "${unit}: a 16,384-slot ${name} takes at most ${ceilingName} before its first connection" run for Http1TlsServer), and the handshake is restarted with real randomness and the key on every accept, as it was (TLS record, "Slots built on the first accept").

A slot never built reads as a free one there too: its connection, alpn and refused answer a connection no slot holds, with no ALPN and not refused, never slot 0's ("TLS: while slot 0 is open, a slot never built reads as a free one: not held, no descriptor, no ALPN, not refused, not slot 0's connection").

readable, next and flush act only on a slot live names, one tls holds with its connection built, so a slot accepted on tls directly reads as free. A cap out of range panics when the connection is made (net_http1_server_bad_config). The input the connection buffers is the largest of chunkSize, a header line and a request line, so any head the caps allow can be read.

No cap lets a peer outgrow a buffer. The buffers a peer's bytes fill — the parser's input and head, the decoder's input — grow by doubling and stop at 2^30, where growing further panics. So the constructor refuses a cap whose buffer could need more: maxMessage above 2^30 − 14, since a frame is buffered whole with its 14-byte header (net_http1_server_bad_message), and maxTarget + maxHeaderBytes above 2^30 − 44, since the head holds the request line beside the header section (net_http1_server_bad_head).

At the largest values accepted, an upgraded slot buffers exactly 2^30 bytes and an HTTP slot less (net_http1_server). The review of #468 found the first (R1-1): before it, a legal maxMessage of 2^30 let one frame panic the process.

Nothing per request on a warmed slot. A hundred GETs and a hundred chunked POSTs on one plain connection, and fifty of each over TLS, move Arena.used() across the servers' calls and the program's answers by 0 bytes (net_http1_server). The parser keeps the head as spans in a buffer it grows to the largest head it has seen and keeps; restart and reset allocate nothing, so a slot is reused for the next connection as it is.

The output is borrowed, not kept: a slot holds a buffer only while it has bytes the socket has not taken, so the plain checks run on one buffer and a slot whose client stops reading holds one until it drains, then gives it back; fifty connections in a row leave the pool's buffers all free (net_http1_server).

Lent input, and what a lent buffer holds (net_http1_server). With Http1Config.idleInput, on by default since the idle trims, a slot gives its parser's input and head buffers to pools its server's slots share (Http1Connection.park, from Http1Server.flush and Http1TlsServer.flush and at restart) only while it rests: speaking HTTP, no request open, and Http1Parser.resting() (waiting for a request line, nothing fed and unread). A slot still reading a head, owing a response, holding pipelined bytes or upgraded keeps both, and unpark takes a buffer back in feed before any byte is copied in.

A lent buffer is not cleared: it holds the bytes of the request it last carried, a password in a body included, until the next slot to take it overwrites them. Nothing reads them, since a parser reads only the window [start, end) it was fed and park resets that window to empty; the bytes stay in the process's memory as they do with the option off, when each slot keeps its own buffer with the same bytes in it. Turning it on by default moves no byte a parser can read: it changes which slot's buffer the bytes sit in until they are overwritten, not whether they are. After park, conn.data and the parser's head, body and input views may point into a pooled buffer another client's slot is about to overwrite; the default is safe because those windows are valid only until the next next() (the doc comments in http1-server.ts), and a slot parks only once its exchange is done.

Tests: two slots served one after the other share one input and one head buffer, a connection with a request open keeps them, so do they while a byte of the next request is unread, and once nothing is open or unread both go back, a pipelined pair on a slot that lent its buffers is answered in order, on the default config the slots lent their input and head buffers to the pools, and without idleInput a resting slot keeps its input buffer.

A lent buffer is taken back by identity, and the layout moves only where fields sit (net_http1_server, _f64, 2026-11-06, written against main at 98c4f9a7).

Http1Parser's fields are ordered hot first (its buffers, the window and scan state, the flags, then the request's numbers, the caps and, last, what only a keepText parser or a response reads), and it makes its spans before its other arrays, so a request on a cold slot touches fewer lines; Http1Connection makes its parser before its HttpDate.

Http1Parser's size stays 200 bytes and no slot holds a new buffer.

unpark first compares a buffer with the slot's noOutput, which park put in its place, and only then runs the length test it ran before.

The comparison is a speed-up and has no behaviour of its own: noOutput is empty, so the length test alone takes the same branch, and an empty buffer that is not noOutput is still swapped for a lent one. What the parser accepts or refuses does not change.

Tests: a slot that lent its buffers holds its noOutput in their place, the first part of a request split across reads takes a lent buffer back, and the rest of it is answered, the buffer lent again after, a request that grows past the lent input buffer is answered, and its slot lends the grown one, the next request on the other slot takes the grown buffer and is answered, both slots resting with their buffers lent are closed past idleTimeout, and their clients see the end, what they lent still in the pools, a peer on a freed slot is served from the pools, a WebSocket handshake on a slot that lent its buffers switches and and closes on a close, in tests/link/net_http1_server and _f64.

ALPN (net_http1_server): a TLS handshake that chose http/1.1, or none, is served; one that chose h2 is shut down with close_notify before any HTTP/1.1 byte.

Idle slots (net_http1_server): expire(now) closes a slot idle past idleTimeout on either carrier and leaves one that has just moved; the client sees the end. It closes a slot whose head is past headTimeout, on either carrier, though bytes keep the slot from being idle — a head in pieces, a head pipelined behind an exchange, a TLS record trickled a byte at a time — and leaves a kept-alive slot whose exchange is over and a slow head that finishes in time (H1-1).

A kept-alive slot quiet past headTimeout is not yet due, so it does not make every expire walk every slot (H1-4). The pool sheds a connection past its size.

Kept response heads (tests/link/net_http1_server_head_reuse, 925 checks, written against main at 9e49a177): respond copies its previous final head only when every input of it is the same, and otherwise writes it fresh through http1WriteResponseHead and its checks, so a kept head cannot carry one response's fields, or a value the writer would refuse, into another. The kept head is the connection's own response buffer (headBytes, sized to the head it keeps rounded up to H1_HEAD_ROUND, 64 bytes, and never past H1_HEAD_KEEP, 1,024, and headLengths, two i32 for each of its fields, at most H1_HEAD_FIELDS, 16); the compare reads only the program's names and values and that buffer, never the parser's request head, so the request head's layout (each field line kept with its CRLF) does not reach it. The checks read every response byte for byte against http1WriteResponseHead called directly, and headCopies says whether it was copied:

  • A head is copied only when the status, the framing, the Connection the request asked for, the HttpDate object and its tick (formats()), the number of fields, each name's and each value's length, and every name and value byte match the kept head; the compare runs on every response. Each input changed alone is written fresh (another status, a value of the same length, changed, a name of the same length in another case, a field fewer, its value never carried over, the fields in another order, the Date tick), and one byte changed at the start, middle and end of a name and of a value of every length from 1 to 33 bytes (each of the compare's byte, four-, eight- and sixteen-byte paths), each against a freshly kept head, is written fresh too. Sixteen fields, the most a kept head holds, are kept and copied; heads of up to three-byte names and values (short fields) take the byte-at-a-time compare. The four- and eight-byte compares' own fallback to bytes is not reachable through respond, since http1ServerKept checks the field fits the kept buffer before it calls them; their guards stay so that no load can pass either array.
  • A value cannot smuggle text past the writer's check. The first version of the compare matched names' lengths but not values', and a last value whose bytes ran on through the kept \r\nDate: …\r\nContent-Length: n matched the kept head byte for byte and was answered with it instead of H1_INVALID; it was fixed before it reached main, by comparing every length first. a last value spanning the kept Date and Content-Length is refused (0 before the fix, H1_INVALID after) and a name spanning two kept lines is refused pin it. The reserved-name check is skipped only on a copy, whose names are those of a head that passed it.
  • A refusal after a copied head is its own: an error after a copied head is that same 505 (the copied head carried X-Secret) and a target past maxTarget is answered 414 and closed read the whole output. A 100 Continue is never kept and does not end the kept head (a 100 after two answers and before a third).
  • The copy is bounded: it runs only when the head fits bodyRoom(), which stops H1_CONTROL_RESERVE short of the output's end. A head one byte too big for the room is held (H1_AGAIN) with nothing copied or queued (the same head with one byte too little room is held, held: nothing queued), and copied once the output drains. A head over 1 KiB is never kept.
  • A slot's next connection starts with no kept head: restart empties it, so a head the last connection kept is neither copied nor taken for a repeat (after the restart: written and after the restart, kept: written fail without it; a copy would have had the same bytes as a fresh write, but the kept head was the last connection's state).
  • Memory is bounded and lazy: the buffer is made at the first head that is kept, so a connection whose heads never repeat their shape holds none, and one that keeps heads holds what its longest kept head needs: its bytes rounded up to 64, two i32 a field and the arrays' own headers, at most about 1.3 KiB (1,024 bytes of head and 128 of lengths). A longer head is remade larger; a shorter one reuses the buffer.
  • Work on a miss is bounded. The compare reads a field with guarded word loads (http1ServerKept: 16-byte nish:simd loads with an overlapping tail from 16 bytes, two u64 loads from 8, two u32 loads from 4, bytes below), each guard checking both arrays, and stops at the first length or byte that differs. A miss after a head of the same shape copies the written head into headBytes (keepHead, at most H1_HEAD_KEEP bytes). After H1_HEAD_MISSES (4) heads in a row are written, respond neither compares nor keeps until the Date turns, so a peer that varies every response pays at most four compares and copies a second per connection, then none (the fourth miss repeated: off, so written, the streak copied nothing past its base, the next second: kept, then copied, a copy ending a streak (round 2, the third miss's head again), and restarted while off: copied).

The program's mistakes panic (one program each): a window outside its buffer in Http1Connection.feed (net_http1_server_feed_window), write (net_http1_server_write_window), sendBody (net_http1_server_send_body_window) and sendFrame (net_http1_server_frame_window), http1WriteChunk (net_http1_write_chunk_window), websocketWriteFrame (net_websocket_write_window), and the parser's and decoder's own feed (net_http1_feed_window, net_websocket_feed_window).

What is and is not wiped

HTTP/1.1 holds no key material: over TLS the record keys are TLS's (docs/security/tls.md). What it holds is application data — the head in the parser's head and input buffers, bodies in the input and output buffers, WebSocket messages in the decoder's — which may carry credentials (cookie, authorization). None of it is wiped: each buffer is overwritten by the next request and zeroed by nothing, and it stays in the slot until then.

An output buffer is the exception to staying in its slot: a pool's slots borrow it from an Http1OutputPool and give it back once sent, so the next connection to write, on any slot, writes over the last one's response from the start. A carrier sends only output[outputStart .. outputEnd), the bytes this connection wrote, so what lies past outputEnd is never sent; it is in the process's memory as it was before, in a buffer that moves between slots.