diff options
author | adamw <adam@warski.org> | 2017-07-24 17:01:20 +0200 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-07-24 17:01:20 +0200 |
commit | b5f0c5387f7a98875f60fdf09c8dbe56e5c2766d (patch) | |
tree | dbfe91d274ed38ad1a85dceb4f3092bc8dc80a9b /async-http-client-handler/src | |
parent | b1a539bd1fb5a5870c2e96c73f14e79b6caf4ff6 (diff) | |
download | sttp-b5f0c5387f7a98875f60fdf09c8dbe56e5c2766d.tar.gz sttp-b5f0c5387f7a98875f60fdf09c8dbe56e5c2766d.tar.bz2 sttp-b5f0c5387f7a98875f60fdf09c8dbe56e5c2766d.zip |
Closing the async http client if created by sttp
Diffstat (limited to 'async-http-client-handler/src')
-rw-r--r-- | async-http-client-handler/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientHandler.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/async-http-client-handler/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientHandler.scala b/async-http-client-handler/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientHandler.scala index f89c85a..1e924a0 100644 --- a/async-http-client-handler/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientHandler.scala +++ b/async-http-client-handler/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientHandler.scala @@ -30,7 +30,8 @@ import scala.language.higherKinds abstract class AsyncHttpClientHandler[R[_], S]( asyncHttpClient: AsyncHttpClient, - rm: MonadAsyncError[R]) + rm: MonadAsyncError[R], + closeClient: Boolean) extends SttpHandler[R, S] { override def send[T](r: Request[T, S]): R[Response[T]] = { @@ -216,6 +217,11 @@ abstract class AsyncHttpClientHandler[R[_], S]( "Requested a streaming response, trying to read eagerly.")) } } + + def close(): Unit = { + if (closeClient) + asyncHttpClient.close() + } } trait MonadAsyncError[R[_]] { |