aboutsummaryrefslogtreecommitdiff
path: root/akka-http-handler
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-07-15 21:16:28 +0200
committeradamw <adam@warski.org>2017-07-15 21:16:28 +0200
commit06e2ae994af39f77d8ee2b7ed367cba0936f35c4 (patch)
tree133491fc8e440a06330dc9be752460439d754c04 /akka-http-handler
parente10115cabebd14f6838fa93e970c3b163d1a64a6 (diff)
downloadsttp-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.scala8
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))
}