Repository navigation
fix(http): accept CR line endings in SSE streams - #198
Open
Elon-Jiang wants to merge 1 commit into
Open
Elon-Jiang wants to merge 1 commit into
Elon-Jiang wants to merge 1 commit into
Conversation
This branch has not been deployed
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
The public Streamable HTTP transport never delivers an SSE event delimited by CR while the connection stays open. LF and CRLF controls deliver normally. SSE permits all three line endings (WHATWG).
Normalize CR and CRLF before the existing line parser. Remember a trailing CR across chunks so the following LF is consumed once, without delaying delivery until another chunk or EOF. The regression covers split CRLF, empty chunks, multibyte UTF-8, multiple data fields and mixed endings; U+0085/U+2028 inside JSON stay unchanged.
Related issues
N/A; found through the Streamable HTTP receive path. Existing #183 handles JSON-RPC batches, not CR framing.
Testing
create_http_stream()→ initialize → receive, with the real HTTPX2 client and a controlled long-lived response stream: unchanged main 4 fail / 3 controls pass, fixed 7 pass.make check: passed.NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1 make test: 547 passed, 1 skipped (optional Gemini), one existing code-generator warning. The initial run had five WebSocket failures because the local environment routed loopback through a SOCKS proxy without its optional dependency; direct loopback passed without source/dependency changes.Only the external HTTP response is supplied by MockTransport; no live agent/model was used. No schema or public API changes.
AI assistance: Codex prepared the patch and ran the listed checks. No human review is claimed.
Docs & screenshots
No public API or schema changes. This restores existing SSE framing behavior; no new configuration, guide or screenshot is needed.
Checklist