Bounded HTTP response streaming with callback backpressure and cancellation.
run/5 returns {:ok, summary} or {:error, %T3.Error{}}. Its callback runs
in an isolated worker and receives {:status, integer}, {:headers, pairs},
and {:data, binary}. Return :cont or :halt (a successful early stop).
The worker waits for the callback before reading more bytes. Capture the
caller PID explicitly when forwarding events; self() inside the callback
is the worker PID. MJPEG, AVCC, files and other binary data are unchanged.
With mode: :sse, {:event, %ConduitMcp.Client.SSE.Event{}} replaces data
callbacks. Parsing uses Conduit's incremental parser; heartbeats/comments
do not generate events, incomplete trailing events are discarded. Event
data is left as text so callers choose JSON decoding. Reconnect/resume is
explicit: there are no retries or automatic Last-Event-ID requests.
Options include :timeout (hard wall-clock deadline, default client timeout),
:idle_timeout, :max_bytes, :max_events, :max_event_bytes, and ordinary
HTTP request options. All bounds must be positive integers. A hard deadline
also stops a blocked callback. Defaults: 16 MiB total bytes (client body cap),
10,000 data deliveries/events, 1 MiB per SSE event/line.
task = T3.HTTP.start_stream(http, :get, "/api/guest/stream", callback,
query: %{"share" => share_id}, mode: :sse, timeout: 60_000)
# Consume the result with Task.await/2, or cancel from its owner process:
T3.HTTP.cancel_stream(task)
Summary
Functions
Stop an owned streaming Task, including its linked network worker.
Run a bounded stream. The callback must return :cont or :halt.
Start a Task. Await or cancel it from the process that called start/5.
Functions
Stop an owned streaming Task, including its linked network worker.
Run a bounded stream. The callback must return :cont or :halt.
Start a Task. Await or cancel it from the process that called start/5.