diff options
author | adamw <adam@warski.org> | 2017-09-13 15:12:49 +0100 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-09-13 15:12:49 +0100 |
commit | 82320c4e764edd493a826de26e6899ae4e2bf518 (patch) | |
tree | f57989f2b08839692d8ff46217916c4d6af378a2 /core/src/test | |
parent | 1347386b75bf5a4784d20ba20d73eea6721b682f (diff) | |
download | sttp-82320c4e764edd493a826de26e6899ae4e2bf518.tar.gz sttp-82320c4e764edd493a826de26e6899ae4e2bf518.tar.bz2 sttp-82320c4e764edd493a826de26e6899ae4e2bf518.zip |
By default, only escaping in queries the & and = reserved characters.
Other (allowed) are left intact. Adding an option to escape all to
the URI API.
Diffstat (limited to 'core/src/test')
-rw-r--r-- | core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala | 4 | ||||
-rw-r--r-- | core/src/test/scala/com/softwaremill/sttp/UriTests.scala | 23 |
2 files changed, 19 insertions, 8 deletions
diff --git a/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala b/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala index e9554df..9fc2d3a 100644 --- a/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala +++ b/core/src/test/scala/com/softwaremill/sttp/UriInterpolatorTests.scala @@ -8,7 +8,7 @@ class UriInterpolatorTests extends FunSuite with Matchers { val v2queryEncoded = "a+c" val v2encoded = "a%20c" val v3 = "a?=&c" - val v3encoded = "a%3F%3D%26c" + val v3encoded = "a?%3D%26c" val v4 = "f/g" val v4encoded = "f%2Fg" val v5 = "a:b" @@ -114,7 +114,7 @@ class UriInterpolatorTests extends FunSuite with Matchers { ), "everything" -> List( (uri"${"http"}://$v1.$v2.com/$v1/$v2?$v1=$v2&$v3=$v4#$v1", - s"http://$v1.$v2encoded.com/$v1/$v2encoded?$v1=$v2queryEncoded&$v3encoded=$v4encoded#$v1") + s"http://$v1.$v2encoded.com/$v1/$v2encoded?$v1=$v2queryEncoded&$v3encoded=$v4#$v1") ), "embed whole url" -> List( (uri"${"http://example.com:123/a"}/b/c", "http://example.com:123/a/b/c"), diff --git a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala index f421413..341533a 100644 --- a/core/src/test/scala/com/softwaremill/sttp/UriTests.scala +++ b/core/src/test/scala/com/softwaremill/sttp/UriTests.scala @@ -1,6 +1,10 @@ package com.softwaremill.sttp -import com.softwaremill.sttp.Uri.{QueryFragment, UserInfo} +import com.softwaremill.sttp.Uri.{ + QueryFragment, + QueryFragmentEncoding, + UserInfo +} import org.scalatest.{FunSuite, Matchers} class UriTests extends FunSuite with Matchers { @@ -31,7 +35,7 @@ class UriTests extends FunSuite with Matchers { List("a b", "z", "ą:ę"), List(QF.KeyValue("p:1", "v&v"), QF.KeyValue("p2", "v v")), None) -> - "http://exa%20mple.com/a%20b/z/%C4%85:%C4%99?p%3A1=v%26v&p2=v+v", + "http://exa%20mple.com/a%20b/z/%C4%85:%C4%99?p:1=v%26v&p2=v+v", Uri("http", Some(UserInfo("us&e/r", Some("pa ss"))), "example.com", @@ -82,10 +86,17 @@ class UriTests extends FunSuite with Matchers { QF.KeyValue("k3", "v3"), QF.KeyValue("k4", "v4")) -> "k1=v1&k2=v2-abc-k3=v3&k4=v4", List(QF.KeyValue("k1", "v1"), QF.Plain("&abc&"), QF.KeyValue("k2", "v2")) -> "k1=v1%26abc%26k2=v2", - List(QF.KeyValue("k1", "v1"), QF.Plain("&abc&", relaxedEncoding = true)) -> "k1=v1&abc&", - List(QF.KeyValue("k1?", "v1?", keyRelaxedEncoding = true)) -> "k1?=v1%3F", - List(QF.KeyValue("k1?", "v1?", valueRelaxedEncoding = true)) -> "k1%3F=v1?", - List(QF.Plain("ą/ę&+;?", relaxedEncoding = true)) -> "%C4%85/%C4%99&+;?" + List( + QF.KeyValue("k1", "v1"), + QF.Plain("&abc&", encoding = QueryFragmentEncoding.Relaxed)) -> "k1=v1&abc&", + List(QF.KeyValue("k1&", "v1&", keyEncoding = QueryFragmentEncoding.Relaxed)) -> "k1&=v1%26", + List(QF.KeyValue( + "k1&", + "v1&", + valueEncoding = QueryFragmentEncoding.Relaxed)) -> "k1%26=v1&", + List(QF.Plain("ą/ę&+;?", encoding = QueryFragmentEncoding.Relaxed)) -> "%C4%85/%C4%99&+;?", + List(QF.KeyValue("k", "v1,v2", valueEncoding = QueryFragmentEncoding.All)) -> "k=v1%2Cv2", + List(QF.KeyValue("k", "v1,v2")) -> "k=v1,v2" ) for { |