Streaming HTTP transport adapter using Finch.
Uses Finch.stream/5 to handle chunked responses and SSE streams. Returns a StreamResponse with an enumerable that yields parsed SSE events.
Configuration
Configure via context transport_opts:
context = %Context{
transport_opts: [
finch: MyApp.Finch, # Finch instance name
receive_timeout: 60_000 # Timeout for receiving data (ms)
]
}Usage
{:ok, response} = FinchStream.stream(request, context)
response.stream
|> Enum.each(fn event ->
IO.puts("Event: #{event.data}")
end)
Summary
Functions
Decode a raw binary SSE body into a list of events.
Functions
@spec decode_sse_body(binary()) :: [Pristine.Streaming.Event.t()]
Decode a raw binary SSE body into a list of events.
This is useful when you have a complete SSE response body and want to parse it into events.
Example
events = FinchStream.decode_sse_body(body)