Repository navigation
Fix SSE stream concurrency and validate metadata-before-body for HTTP/JSON and JSON-RPC streams - #147
Merged
MisterVVP merged 18 commits intoJul 13, 2026
Conversation
MisterVVP
merged commit Jul 13, 2026
ac860ac
into
dev-add-sse-streaming-support-to-clients
16 checks passed
MisterVVP
added a commit
that referenced
this pull request
Jul 19, 2026
…/JSON and JSON-RPC streams (#147) ### Motivation - Prevent long-lived SSE streams from serializing other streams on the same shared libcurl easy handle by avoiding holding the shared handle/mutex across `curl_easy_perform`. - Ensure JSON-RPC and HTTP+JSON SSE transports validate response metadata (`A2A-Version`, HTTP 2xx status, exact `text/event-stream` media type) before any SSE body chunk is parsed or dispatched. - Keep the shared HTTP helper approach so transports reuse common protocol utilities for header/media-type handling. ### Description - Use a per-stream RAII-managed libcurl easy handle (`CurlEasyHandle`) in `a2a::http::Client::StreamRequest(...)` so long-lived streams do not block other streams and no shared mutex is held across `curl_easy_perform(...)`. - Extend the streaming requester contract with a metadata callback: add `HttpStreamMetadataHandler` and change `HttpStreamRequester` to accept `on_metadata` before chunk callbacks so metadata can be delivered prior to any body. - Make libcurl stream path invoke the metadata callback after headers/status are known (via `ValidateStreamMetadata`) and before the first body chunk is forwarded. - In `HttpJsonTransport` and `JsonRpcTransport` streaming workers, validate metadata-first (A2A-Version via shared `ValidateResponseVersion`, HTTP 2xx range, and exact SSE media type using shared `core::http::IsSseContentType`) and only allow parser feeding after metadata passes validation. - Preserve cancellation semantics and single-terminal-callback contract (exactly one `OnError` or `OnCompleted`, no events after terminal callback). - Keep unary `SendRequest(...)` unchanged with shared handle semantics (only streaming was changed to keep diff small). - Add deterministic tests and test helpers: per-stream concurrency test proving two streams do not serialize, and adjustments to existing HTTP+JSON and JSON-RPC streaming tests to exercise metadata-before-body and `text/event-streaming` rejection paths. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.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.
Motivation
curl_easy_perform.A2A-Version, HTTP 2xx status, exacttext/event-streammedia type) before any SSE body chunk is parsed or dispatched.Description
CurlEasyHandle) ina2a::http::Client::StreamRequest(...)so long-lived streams do not block other streams and no shared mutex is held acrosscurl_easy_perform(...).HttpStreamMetadataHandlerand changeHttpStreamRequesterto accepton_metadatabefore chunk callbacks so metadata can be delivered prior to any body.ValidateStreamMetadata) and before the first body chunk is forwarded.HttpJsonTransportandJsonRpcTransportstreaming workers, validate metadata-first (A2A-Version via sharedValidateResponseVersion, HTTP 2xx range, and exact SSE media type using sharedcore::http::IsSseContentType) and only allow parser feeding after metadata passes validation.OnErrororOnCompleted, no events after terminal callback).SendRequest(...)unchanged with shared handle semantics (only streaming was changed to keep diff small).text/event-streamingrejection paths.