aboutsummaryrefslogtreecommitdiff
path: root/async-http-client-backend/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/AsyncHttpClientFutureBackend.scala
diff options
context:
space:
mode:
Diffstat (limited to 'async-http-client-backend/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/AsyncHttpClientFutureBackend.scala')
-rw-r--r--async-http-client-backend/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/AsyncHttpClientFutureBackend.scala51
1 files changed, 15 insertions, 36 deletions
diff --git a/async-http-client-backend/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/AsyncHttpClientFutureBackend.scala b/async-http-client-backend/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/AsyncHttpClientFutureBackend.scala
index 6778fa0..d91f404 100644
--- a/async-http-client-backend/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/AsyncHttpClientFutureBackend.scala
+++ b/async-http-client-backend/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/AsyncHttpClientFutureBackend.scala
@@ -3,37 +3,22 @@ package com.softwaremill.sttp.asynchttpclient.future
import java.nio.ByteBuffer
import com.softwaremill.sttp.asynchttpclient.AsyncHttpClientBackend
-import com.softwaremill.sttp.{
- FollowRedirectsBackend,
- FutureMonad,
- SttpBackend,
- SttpBackendOptions
-}
-import org.asynchttpclient.{
- AsyncHttpClient,
- AsyncHttpClientConfig,
- DefaultAsyncHttpClient
-}
+import com.softwaremill.sttp.{FollowRedirectsBackend, FutureMonad, SttpBackend, SttpBackendOptions}
+import org.asynchttpclient.{AsyncHttpClient, AsyncHttpClientConfig, DefaultAsyncHttpClient}
import org.reactivestreams.Publisher
import scala.concurrent.{ExecutionContext, Future}
-class AsyncHttpClientFutureBackend private (
- asyncHttpClient: AsyncHttpClient,
- closeClient: Boolean)(implicit ec: ExecutionContext)
- extends AsyncHttpClientBackend[Future, Nothing](asyncHttpClient,
- new FutureMonad,
- closeClient) {
+class AsyncHttpClientFutureBackend private (asyncHttpClient: AsyncHttpClient, closeClient: Boolean)(
+ implicit ec: ExecutionContext)
+ extends AsyncHttpClientBackend[Future, Nothing](asyncHttpClient, new FutureMonad, closeClient) {
- override protected def streamBodyToPublisher(
- s: Nothing): Publisher[ByteBuffer] = s // nothing is everything
+ override protected def streamBodyToPublisher(s: Nothing): Publisher[ByteBuffer] = s // nothing is everything
- override protected def publisherToStreamBody(
- p: Publisher[ByteBuffer]): Nothing =
+ override protected def publisherToStreamBody(p: Publisher[ByteBuffer]): Nothing =
throw new IllegalStateException("This backend does not support streaming")
- override protected def publisherToString(
- p: Publisher[ByteBuffer]): Future[String] =
+ override protected def publisherToString(p: Publisher[ByteBuffer]): Future[String] =
throw new IllegalStateException("This backend does not support streaming")
}
@@ -41,8 +26,7 @@ object AsyncHttpClientFutureBackend {
private def apply(asyncHttpClient: AsyncHttpClient, closeClient: Boolean)(
implicit ec: ExecutionContext): SttpBackend[Future, Nothing] =
- new FollowRedirectsBackend[Future, Nothing](
- new AsyncHttpClientFutureBackend(asyncHttpClient, closeClient))
+ new FollowRedirectsBackend[Future, Nothing](new AsyncHttpClientFutureBackend(asyncHttpClient, closeClient))
/**
* @param ec The execution context for running non-network related operations,
@@ -50,10 +34,8 @@ object AsyncHttpClientFutureBackend {
* context.
*/
def apply(options: SttpBackendOptions = SttpBackendOptions.Default)(
- implicit ec: ExecutionContext = ExecutionContext.Implicits.global)
- : SttpBackend[Future, Nothing] =
- AsyncHttpClientFutureBackend(AsyncHttpClientBackend.defaultClient(options),
- closeClient = true)
+ implicit ec: ExecutionContext = ExecutionContext.Implicits.global): SttpBackend[Future, Nothing] =
+ AsyncHttpClientFutureBackend(AsyncHttpClientBackend.defaultClient(options), closeClient = true)
/**
* @param ec The execution context for running non-network related operations,
@@ -61,18 +43,15 @@ object AsyncHttpClientFutureBackend {
* context.
*/
def usingConfig(cfg: AsyncHttpClientConfig)(
- implicit ec: ExecutionContext = ExecutionContext.Implicits.global)
- : SttpBackend[Future, Nothing] =
- AsyncHttpClientFutureBackend(new DefaultAsyncHttpClient(cfg),
- closeClient = true)
+ implicit ec: ExecutionContext = ExecutionContext.Implicits.global): SttpBackend[Future, Nothing] =
+ AsyncHttpClientFutureBackend(new DefaultAsyncHttpClient(cfg), closeClient = true)
/**
* @param ec The execution context for running non-network related operations,
* e.g. mapping responses. Defaults to the global execution
* context.
*/
- def usingClient(client: AsyncHttpClient)(implicit ec: ExecutionContext =
- ExecutionContext.Implicits.global)
- : SttpBackend[Future, Nothing] =
+ def usingClient(client: AsyncHttpClient)(
+ implicit ec: ExecutionContext = ExecutionContext.Implicits.global): SttpBackend[Future, Nothing] =
AsyncHttpClientFutureBackend(client, closeClient = false)
}