Streaming

note

Streaming - 图1

This help topic is in development and will be updated in the future.

Most of the response types are complete in memory. But you can also fetch streaming data as well.

Scoped streaming

There are multiple ways of doing streaming. The safest way is using HttpStatement with scoped execute block:

  1. client.get<HttpStatement>.execute { response: HttpResponse ->
  2. // Response is not downloaded here.
  3. val channel = response.receive<ByteReadChannel>()
  4. }

After execute block is finished, network resources is released.

You can also point different type for execute method:

  1. client.get<HttpStatement>.execute<ByteReadChannel> { channel: ByteReadChannel ->
  2. // ...
  3. }