tesla icon indicating copy to clipboard operation
tesla copied to clipboard

Streaming Response

Open leifg opened this issue 5 years ago • 2 comments

According to the README, Tesla supports streaming if the underlying adapter supports it.

From the code and the examples I found it seems though that streaming means in this instance, streaming of the request.

I am interested in how I would be able to stream the response of a request (very useful for something like large downloads).

Is this supported, if so: how?

leifg avatar Dec 18 '18 13:12 leifg

Unfortunately streaming response body is not implemented, but it could be done. I can imagine something like:

case Tesla.get(client, "/stream", stream_response: true) do
  {:ok, env} -> # on successful read of status & headers env.body is a Stream
  {:error, reason} -> # ...
end

teamon avatar Jan 03 '19 15:01 teamon

I'd go with Tesla.get(client, "/path", response: :stream) (instead of stream_response: true)

teamon avatar May 08 '22 07:05 teamon

Response streaming added for Finch in https://github.com/elixir-tesla/tesla/releases/tag/v1.9.0

teamon avatar Apr 11 '24 19:04 teamon