HTTP.Stream (http_fetch v0.11.0)
View SourceProcess-backed readable stream used for Fetch-style response and request bodies.
Streamed responses expose this PID in HTTP.Response.body. Streaming uploads can
pass a stream PID as body when HTTP.fetch/2 is called with duplex: "half".
Producers write chunks with chunk/3 and finish with finish/1; consumers read
by sending {:read_chunk, pid} or {:read_chunk, pid, :ack}.
Summary
Functions
Creates a stream from an enumerable.
Functions
@spec finish(pid()) :: :ok
@spec from_enumerable(Enumerable.t()) :: {:ok, pid()} | {:error, term()}
Creates a stream from an enumerable.
Each enumerable item is converted to binary and emitted with backpressure. The returned PID can be passed as a streaming request body:
{:ok, stream} = HTTP.Stream.from_enumerable(["hello", " ", "world"])
HTTP.fetch(url, method: :post, body: stream, duplex: "half")
@spec start_link(non_neg_integer()) :: {:ok, pid()}