diff options
Diffstat (limited to 'core/src/test')
-rw-r--r-- | core/src/test/scala/com/softwaremill/sttp/RequestTests.scala | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/src/test/scala/com/softwaremill/sttp/RequestTests.scala b/core/src/test/scala/com/softwaremill/sttp/RequestTests.scala index e6db3d7..c6132c9 100644 --- a/core/src/test/scala/com/softwaremill/sttp/RequestTests.scala +++ b/core/src/test/scala/com/softwaremill/sttp/RequestTests.scala @@ -40,4 +40,29 @@ class RequestTests extends FlatSpec with Matchers { .find(_._1 == CookieHeader) .map(_._2) should be(Some("k1=v1; k2=v2")) } + + "content length" should "be automatically set for a string body" in { + sttp + .body("test") + .headers + .find(_._1.equalsIgnoreCase(ContentLengthHeader)) + .map(_._2) should be(Some("4")) + } + + it should "be automatically set to the number of utf-8 bytes in a string" in { + sttp + .body("ąęć") + .headers + .find(_._1.equalsIgnoreCase(ContentLengthHeader)) + .map(_._2) should be(Some("6")) + } + + it should "not override an already specified content length" in { + sttp + .contentLength(10) + .body("a") + .headers + .find(_._1.equalsIgnoreCase(ContentLengthHeader)) + .map(_._2) should be(Some("10")) + } } |