feat: WebSocket upgrade and text echo on http::server#21
Merged
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Add RFC 6455 framing, Sec-WebSocket-Accept, and server.ws(path).ws(handler) registration. Upgrade takes over the connection after 101; middleware stays HTTP-phase only. Includes unit and loopback echo tests. Co-authored-by: Cursor <cursoragent@cursor.com>
Add unit tests exercising previously-uncovered paths: - unmasked server frame round-trip - 64-bit extended length frames - read_frame rejection of oversized (>1 MiB) and truncated payloads - run_text_session text echo, nullopt suppression, ping->pong, pong-ignore, and close handshake termination Uses an in-memory duplex stream helper so run_text_session is exercised without a socket, so the new cases run even when network tests are disabled. Co-authored-by: Kaius Ruokonen <ruoka@users.noreply.github.com>
Per RFC 6455 5.1, client-to-server frames must be masked. run_text_session now rejects any unmasked incoming frame with a 1002 (protocol error) close and ends the session. Adds close status-code constants and a make_close_frame overload that carries a 2-byte big-endian code. Co-authored-by: Kaius Ruokonen <ruoka@users.noreply.github.com>
Co-authored-by: Kaius Ruokonen <ruoka@users.noreply.github.com>
Fail closed with close codes: no fragmentation/binary (1003), invalid UTF-8 (1007), oversized payloads (1009), RSV/control violations (1002). UTF-8 validation is self-contained in net (no xson dependency). Co-authored-by: Cursor <cursoragent@cursor.com>
Provide a minimal text client matching the server spike: HTTP upgrade, masked outbound frames, automatic ping/pong, and close handshake. Co-authored-by: Cursor <cursoragent@cursor.com>
Name the optional outbound payload and drop trailing return types on
handler lambdas in favor of return text_reply{…}.
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
net:websocket_frame) and accept-key + session loop (net:websocket)http::server::ws(path).ws(handler)registration; GET +Upgrade: websocket→101then text session (ping/pong/close/echo)callback_with_headersmiddlewareTest plan
./tools/CB.sh debug build --jsonl=failuresNET_DISABLE_NETWORK_TESTS=0 ./tools/CB.sh debug test --jsonl=failures --tags='\[net\]'(455/455)Made with Cursor