fix(sse): preserve event state and validate streaming responses - #32
rupayon123 wants to merge 10 commits into
Conversation
|
Additional fixes pushed to this branch:
Full Go tests, go vet and build pass, including a live local streaming server that previously hung after an output failure. The stream now closes promptly and preserves the original write error. A subsequent cleanup separates event formatting from connection lifecycle. Today's changes have no new findings under golangci-lint v2.13.2 using a migrated copy of the repository configuration. This is a scoped lint result: a full CLI-branch scan still reports 93 findings outside today's changes; the legacy v1 linter cannot read the installed Go 1.27 export format. Prepared with AI assistance. Changes are submitted for review; this is not a claim of maintainer approval. |
|
September 16 verified update: Invalid UTF-8 in SSE input now produces replacement characters rather than leaking invalid byte sequences. The regression failed before the fix; the full Go suite, vet, build and scoped lint pass after it. Commits: Exact current head: AI-assisted with OpenAI Codex; changes and validation were inspected before submission. |
Problem and change
Bring SSE parsing and streaming behavior in line with event-stream semantics. Preserve empty data fields and persistent event IDs/retry intervals; accept CR, LF, CRLF and a leading UTF-8 BOM; and reject invalid retry values.
The streaming follow-up fixes effective event filtering: untyped events use
message, and event names match exactly rather than case-insensitively. Validate the response media type before creating an output log, so an HTML/JSON error response cannot overwrite a prior log. Support data lines smaller than 1 MiB with a documented bounded scanner rather than failing on ordinary 128 KiB payloads.Custom SSE headers now honor case-insensitive
Hostoverrides through the request host field, and malformed headers are rejected before making a network request.Validation
env -u NO_COLOR go test ./...,go vet ./..., formatting and diff checks pass after each change.golangci-lintis unavailable locally. No claim of automatic reconnection is made.Prepared with AI assistance.