From b1a539bd1fb5a5870c2e96c73f14e79b6caf4ff6 Mon Sep 17 00:00:00 2001 From: adamw Date: Mon, 24 Jul 2017 16:57:51 +0200 Subject: Adding streaming to the monix async http client handler --- .../scalaz/ScalazAsyncHttpClientHandler.scala | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'async-http-client-handler/scalaz') diff --git a/async-http-client-handler/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/ScalazAsyncHttpClientHandler.scala b/async-http-client-handler/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/ScalazAsyncHttpClientHandler.scala index cb3bdef..0460fff 100644 --- a/async-http-client-handler/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/ScalazAsyncHttpClientHandler.scala +++ b/async-http-client-handler/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/ScalazAsyncHttpClientHandler.scala @@ -1,5 +1,7 @@ package com.softwaremill.sttp.asynchttpclient.scalaz +import java.nio.ByteBuffer + import com.softwaremill.sttp.asynchttpclient.{ AsyncHttpClientHandler, MonadAsyncError @@ -9,12 +11,21 @@ import org.asynchttpclient.{ AsyncHttpClientConfig, DefaultAsyncHttpClient } +import org.reactivestreams.Publisher import scalaz.{-\/, \/-} import scalaz.concurrent.Task class ScalazAsyncHttpClientHandler private (asyncHttpClient: AsyncHttpClient) - extends AsyncHttpClientHandler[Task](asyncHttpClient, TaskMonad) + extends AsyncHttpClientHandler[Task, Nothing](asyncHttpClient, TaskMonad) { + + override protected def streamBodyToPublisher( + s: Nothing): Publisher[ByteBuffer] = s // nothing is everything + + override protected def publisherToStreamBody( + p: Publisher[ByteBuffer]): Nothing = + throw new IllegalStateException("This handler does not support streaming") +} object ScalazAsyncHttpClientHandler { def apply(): ScalazAsyncHttpClientHandler = -- cgit v1.2.3