diff options
author | adamw <adam@warski.org> | 2017-07-24 16:57:51 +0200 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-07-24 16:57:51 +0200 |
commit | b1a539bd1fb5a5870c2e96c73f14e79b6caf4ff6 (patch) | |
tree | 6ef95abd69930cabb5b7566507af6dc56d25ebaf /README.md | |
parent | 95fee5083274bf0e856af8b868702f8965b92f1a (diff) | |
download | sttp-b1a539bd1fb5a5870c2e96c73f14e79b6caf4ff6.tar.gz sttp-b1a539bd1fb5a5870c2e96c73f14e79b6caf4ff6.tar.bz2 sttp-b1a539bd1fb5a5870c2e96c73f14e79b6caf4ff6.zip |
Adding streaming to the monix async http client handler
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -289,7 +289,44 @@ implicit val sttpHandler = FutureAsyncHttpClientHandler.usingConfig(asyncHttpCli implicit val sttpHandler = FutureAsyncHttpClientHandler.usingClient(asyncHttpClient) ``` -Streaming is not (yet) supported. +#### Streaming using Monix + +Currently, only the Monix handler supports streaming (as both Monix and Async +Http Client support reactive streams `Publisher`s out of the box). The type of +supported streams in this case is `Observable[ByteBuffer]`. That is, you can +set such an observable as a request body: + +```scala +import com.softwaremill.sttp._ + +import java.nio.ByteBuffer +import monix.reactive.Observable + +val obs: Observable[ByteBuffer] = ... + +sttp + .streamBody(obs) + .post(uri"...") +``` + +And receive responses as an observable stream: + +```scala +import com.softwaremill.sttp._ +import com.softwaremill.sttp.asynchttpclient.monix._ + +import java.nio.ByteBuffer +import monix.eval.Task +import monix.reactive.Observable + +implicit val sttpHandler = MonixAsyncHttpClientHandler() + +val response: Task[Response[Observable[ByteBuffer]]] = + sttp + .post(uri"...") + .response(asStream[Observable[ByteBuffer]]) + .send() +``` ## Request type |