Repository navigation
Conversation
Add an early prototype of the WinterTC Fetch Server API proposal (https://fetch-server.proposal.wintertc.org/), exposed as `http.fetchServer` behind the new `--experimental-http-serve` flag. This includes: * `ServerResponse`, `ServerHeaders`, and `ServerRequest` with iterable-stream bodies, trailers, and cloning. * The `ServerContext` and `ConnectContext` protocols, the exchange state model, informational responses, 100-continue handling, `deny()`, `waitUntil()`, and `completed`. * The handler model, including the error() handler and fallbacks. * `serve()`, `Server`, and `Listener`, built on the existing `node:http` and `node:http2` implementations, with HTTP/1.1, h2c (prior knowledge), and TLS with ALPN negotiation of h2. HTTP/3, QUIC, WebTransport, and HTTP/3 datagrams are not supported and throw NotSupportedError. WebSocket upgrades are not implemented yet. Assisted-by: Claude Opus 5.5 Signed-off-by: James M Snell <jasnell@gmail.com>
Add tests for CONNECT, extended CONNECT, HTTP/1.1 upgrade normalization, fall-through, and capsules over HTTP/2, and fix the issues they found: * Defer the RST_STREAM(NO_ERROR) that refuses an unread request body until the complete response has been sent, and only send it if the client has not already ended its side. * Send `Content-Length: 0` for HTTP/1.1 responses without a body. Assisted-by: Claude Opus 5.5 Signed-off-by: James M Snell <jasnell@gmail.com>
Implement `upgradeWebSocket()` and `upgradeWebSocketStream()` for HTTP/1.1 upgrades and HTTP/2 extended CONNECT (RFC 8441), with: * RFC 6455 framing: masking, fragmentation, ping/pong, the closing handshake, UTF-8 validation, and failing the connection on protocol violations. * A server-side `WebSocket` with the WHATWG event API, whose close() accepts the close codes that a server can send. * `ServerWebSocketStream`, whose readable and writable streams apply backpressure in both directions. * Subprotocol selection by server preference, opt-in permessage-deflate (RFC 7692), `pingInterval`, and the `closeHandshake` and `tunnelIdle` timeouts. * Close code 1001 on graceful server shutdown. Assisted-by: Claude Opus 5.5 Signed-off-by: James M Snell <jasnell@gmail.com>
Add a self-contained "Fetch Server API" section to the `node:http` documentation, covering `http.fetchServer.serve()`, the handler model, `Server`, `Listener`, `ServerResponse`, the context and request protocols, tunnels, WebSocket upgrades, protocol errors, and the limitations of the prototype. Assisted-by: Claude Opus 5.5 Signed-off-by: James M Snell <jasnell@gmail.com>
Add benchmarks for the fetch() handler of the experimental `http.fetchServer` API over HTTP/1.1 and HTTP/2, each with and without TLS. Let the HTTP/2 test double connect to servers with self-signed certificates, as the HTTPS test double already does. Assisted-by: Claude Opus 5.5 Signed-off-by: James M Snell <jasnell@gmail.com>
Collaborator
|
Review requested:
|
Profiling showed that a response with a small body made two writes and several promise races, and paid for request state that was not used. * Send a body that is held as bytes, such as one from a string or a Uint8Array, with its Content-Length in a single write, instead of with chunked encoding in separate writes. * Race exchange operations against an abort with a single promise that `abort()` rejects, instead of `SafePromiseRace()`. This also stops every race from adding a reaction to a promise that lives as long as the exchange. * Hold the state of a context in a private field instead of a non-enumerable property. * Build the HTTP/1.1 request header list lazily, without copying the hop-by-hop field set, and do not create the ServerRequest to check for HEAD. Assisted-by: Claude Opus 5.5
|
Looks like https://fetch-server.proposal.wintertc.org/ is not yet online? I found this link instead, if that helps -> https://proposal-fetch-server.jasnell.me/ Also this repo -> https://github.com/jasnell/proposal-fetch-server |
Member
|
this is sick, great work @jasnell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an early prototype of the Fetch Server API proposal
(https://fetch-server.proposal.wintertc.org/), exposed as
http.fetchServerbehind the new--experimental-http-serveflag.The fundamental idea is a HTTP server API that is HTTP version agnostic and supports the full range of newer HTTP features like tunnels, unreliable datagrams, WebTransport (once QUIC/H3 are done), etc.
HTTP/3, QUIC, WebTransport, and HTTP/3 datagrams are not supported and
throw NotSupportedError.
WebSocket upgrades are not implemented yet.This has not yet been performance optimized and it's definitely slower than the current API.
Consider it a proof of concept.
Extremely experimental and very much in flux.
Some notes on the design:
@nodejs/quic @nodejs/http @nodejs/http2 @mcollina