diff options
author | adamw <adam@warski.org> | 2017-07-15 21:16:28 +0200 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-07-15 21:16:28 +0200 |
commit | 06e2ae994af39f77d8ee2b7ed367cba0936f35c4 (patch) | |
tree | 133491fc8e440a06330dc9be752460439d754c04 /akka-http-handler | |
parent | e10115cabebd14f6838fa93e970c3b163d1a64a6 (diff) | |
download | sttp-06e2ae994af39f77d8ee2b7ed367cba0936f35c4.tar.gz sttp-06e2ae994af39f77d8ee2b7ed367cba0936f35c4.tar.bz2 sttp-06e2ae994af39f77d8ee2b7ed367cba0936f35c4.zip |
Response as parameters
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)) } |