diff options
author | adamw <adam@warski.org> | 2017-07-24 17:23:32 +0200 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-07-24 17:23:32 +0200 |
commit | a568123e2a7959b860faaedb66b358fabd92e317 (patch) | |
tree | 308bb70644ed738eef1bfe19f34fa400fb28d90e /core/src/test | |
parent | fc62bf67b23793b3766f527de5ffac73e78d2d18 (diff) | |
download | sttp-a568123e2a7959b860faaedb66b358fabd92e317.tar.gz sttp-a568123e2a7959b860faaedb66b358fabd92e317.tar.bz2 sttp-a568123e2a7959b860faaedb66b358fabd92e317.zip |
Automatically setting content-length, where possible
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")) + } } |