aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-07-24 16:57:51 +0200
committeradamw <adam@warski.org>2017-07-24 16:57:51 +0200
commitb1a539bd1fb5a5870c2e96c73f14e79b6caf4ff6 (patch)
tree6ef95abd69930cabb5b7566507af6dc56d25ebaf /README.md
parent95fee5083274bf0e856af8b868702f8965b92f1a (diff)
downloadsttp-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.md39
1 files changed, 38 insertions, 1 deletions
diff --git a/README.md b/README.md
index c5ca897..b843226 100644
--- a/README.md
+++ b/README.md
@@ -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