aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala
index de033df..a2b9505 100644
--- a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala
+++ b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala
@@ -170,6 +170,17 @@ class BasicTests
akka.pattern.after(1.second, using = actorSystem.scheduler)(
Future.successful("Done"))
}
+ } ~ path("empty_unauthorized_response") {
+ post {
+ import akka.http.scaladsl.model._
+ complete(
+ HttpResponse(
+ status = StatusCodes.Unauthorized,
+ headers = Nil,
+ entity = HttpEntity.Empty,
+ protocol = HttpProtocols.`HTTP/1.1`
+ ))
+ }
}
override def port = 51823
@@ -220,6 +231,7 @@ class BasicTests
multipartTests()
redirectTests()
timeoutTests()
+ emptyResponseTests()
def parseResponseTests(): Unit = {
name should "parse response as string" in {
@@ -664,6 +676,18 @@ class BasicTests
request.send().force().unsafeBody should be("Done")
}
}
+
+ def emptyResponseTests(): Unit = {
+ val postEmptyResponse = sttp
+ .post(uri"$endpoint/empty_unauthorized_response")
+ .body("{}")
+ .contentType("application/json")
+
+ name should "parse an empty error response as empty string" in {
+ val response = postEmptyResponse.send().force()
+ response.body should be(Left(""))
+ }
+ }
}
override protected def afterAll(): Unit = {