diff options
Diffstat (limited to 'akka-http-handler')
-rw-r--r-- | akka-http-handler/src/main/scala/com/softwaremill/sttp/akkahttp/AkkaHttpSttpHandler.scala | 8 |
1 files changed, 7 insertions, 1 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 a22c7cf..866aaad 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 @@ -58,17 +58,23 @@ class AkkaHttpSttpHandler(actorSystem: ActorSystem) .runFold(ByteString(""))(_ ++ _) .map(_.toArray[Byte]) + def asString(enc: String) = + asByteArray.map(new String(_, enc)) + rr match { case IgnoreResponse => hr.discardEntityBytes() Future.successful(()) case ResponseAsString(enc) => - asByteArray.map(new String(_, enc)) + asString(enc) case ResponseAsByteArray => asByteArray + case r @ ResponseAsParams(enc) => + asString(enc).map(r.parse) + case r @ ResponseAsStream() => Future.successful(r.responseIsStream(hr.entity.dataBytes)) } |