diff options
author | adamw <adam@warski.org> | 2017-07-04 14:14:27 +0200 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-07-04 14:14:27 +0200 |
commit | 66eed168fa5b9868ffcee5fe1cf698148cfb5264 (patch) | |
tree | ded55762fb03c05a206d2e1cd3a9b9dedf540f95 | |
parent | 3aefd7447ae8f15ecd9a3401b9dd6992c4197aec (diff) | |
download | sttp-66eed168fa5b9868ffcee5fe1cf698148cfb5264.tar.gz sttp-66eed168fa5b9868ffcee5fe1cf698148cfb5264.tar.bz2 sttp-66eed168fa5b9868ffcee5fe1cf698148cfb5264.zip |
Comments
3 files changed, 10 insertions, 5 deletions
diff --git a/akka-http-handler/src/main/scala/com/softwaremill/sttp/akkahttp/AkkaHttpSttpHandler.scala b/akka-http-handler/src/main/scala/com/softwaremill/sttp/akkahttp/AkkaHttpSttpHandler.scala index 668da90..7331065 100644 --- a/akka-http-handler/src/main/scala/com/softwaremill/sttp/akkahttp/AkkaHttpSttpHandler.scala +++ b/akka-http-handler/src/main/scala/com/softwaremill/sttp/akkahttp/AkkaHttpSttpHandler.scala @@ -59,8 +59,8 @@ class AkkaHttpSttpHandler(actorSystem: ActorSystem) case ResponseAsByteArray => asByteArray - case r @ ResponseAsStream() => - Future.successful(r.x(hr.entity.dataBytes)) + case r@ResponseAsStream() => + Future.successful(r.responseIsStream(hr.entity.dataBytes)) } } diff --git a/core/src/main/scala/com/softwaremill/sttp/model/package.scala b/core/src/main/scala/com/softwaremill/sttp/model/package.scala index 24c5fa6..784b72c 100644 --- a/core/src/main/scala/com/softwaremill/sttp/model/package.scala +++ b/core/src/main/scala/com/softwaremill/sttp/model/package.scala @@ -38,6 +38,10 @@ package object model { case class FileBody(f: File) extends BasicRequestBody case class PathBody(f: Path) extends BasicRequestBody + /** + * @tparam T Target type as which the response will be read. + * @tparam S If `T` is a stream, the type of the stream. Otherwise, `Nothing`. + */ sealed trait ResponseAs[T, +S] sealed trait ResponseAsBasic[T, +S] extends ResponseAs[T, S] @@ -46,5 +50,5 @@ package object model { object ResponseAsByteArray extends ResponseAsBasic[Array[Byte], Nothing] // response as params - case class ResponseAsStream[T, S]()(implicit val x: S =:= T) extends ResponseAs[T, S] + case class ResponseAsStream[T, S]()(implicit val responseIsStream: S =:= T) extends ResponseAs[T, S] } diff --git a/core/src/main/scala/com/softwaremill/sttp/package.scala b/core/src/main/scala/com/softwaremill/sttp/package.scala index 8abea0a..8dd8c5d 100644 --- a/core/src/main/scala/com/softwaremill/sttp/package.scala +++ b/core/src/main/scala/com/softwaremill/sttp/package.scala @@ -150,8 +150,9 @@ package object sttp { * to consume it. An exception to this are streaming responses, which need to fully consumed * by the client if such a response type is requested. */ - def send[R[_], S, T, ResponseAsType[x, s] <: ResponseAs[x, s]](responseAs: ResponseAsType[T, S])( - implicit handler: SttpHandler[R, S, ResponseAsType], isRequest: IsRequest[U]): R[Response[T]] = { + def send[R[_], S, T, TypeOfResponseAs[x, s] <: ResponseAs[x, s]](responseAs: TypeOfResponseAs[T, S])( + implicit handler: SttpHandler[R, S, TypeOfResponseAs], isRequest: IsRequest[U]): R[Response[T]] = { + handler.send(this, responseAs) } } |