diff options
author | Piotr Gabara <piotr.gabara@hotmail.com> | 2017-08-27 20:06:52 +0200 |
---|---|---|
committer | Piotr Gabara <piotr.gabara@hotmail.com> | 2017-09-05 16:37:22 +0200 |
commit | e82346820797bb2d80d0fada7f17c5880871edce (patch) | |
tree | 1b972cfffadb9de0f6f0c99f842ada1d58662fb8 /async-http-client-handler/fs2/src/main | |
parent | febcdbcb4448fe1e754ecd08fb4df4bf6c6a211c (diff) | |
download | sttp-e82346820797bb2d80d0fada7f17c5880871edce.tar.gz sttp-e82346820797bb2d80d0fada7f17c5880871edce.tar.bz2 sttp-e82346820797bb2d80d0fada7f17c5880871edce.zip |
Make read and connection timeout configurable
Diffstat (limited to 'async-http-client-handler/fs2/src/main')
-rw-r--r-- | async-http-client-handler/fs2/src/main/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2Handler.scala | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/async-http-client-handler/fs2/src/main/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2Handler.scala b/async-http-client-handler/fs2/src/main/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2Handler.scala index 56e7b8c..8d38f43 100644 --- a/async-http-client-handler/fs2/src/main/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2Handler.scala +++ b/async-http-client-handler/fs2/src/main/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2Handler.scala @@ -21,6 +21,7 @@ import org.asynchttpclient.{ import org.reactivestreams.Publisher import scala.concurrent.ExecutionContext +import scala.concurrent.duration.FiniteDuration import scala.language.higherKinds class AsyncHttpClientFs2Handler[F[_]: Effect] private ( @@ -63,11 +64,13 @@ object AsyncHttpClientFs2Handler { * e.g. mapping responses. Defaults to the global execution * context. */ - def apply[F[_]: Effect]()( + def apply[F[_]: Effect](connectionTimeout: FiniteDuration = SttpHandler.DefaultConnectionTimeout)( implicit ec: ExecutionContext = ExecutionContext.Implicits.global) : SttpHandler[F, Stream[F, ByteBuffer]] = - AsyncHttpClientFs2Handler[F](new DefaultAsyncHttpClient(), - closeClient = true) + AsyncHttpClientFs2Handler[F]( + new DefaultAsyncHttpClient( + AsyncHttpClientHandler.withConnectionTimeout(connectionTimeout)), + closeClient = true) /** * @param ec The execution context for running non-network related operations, |