Skip to content

Commit

Permalink
Change string part encoder (#2193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pask423 authored Jun 5, 2024
1 parent 7c1968d commit 50c5295
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ val zio1InteropRsVersion = "1.3.12"
val zio2InteropRsVersion = "2.0.2"

val oxVersion = "0.2.0"
val sttpModelVersion = "1.7.10"
val sttpModelVersion = "1.7.11"
val sttpSharedVersion = "1.3.19"

val logback = "ch.qos.logback" % "logback-classic" % "1.5.6"
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/sttp/client4/requestBody.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ object BasicBody {
private[client4] def paramsToStringBody(fs: Seq[(String, String)], encoding: String): StringBody = {
val b = fs
.map { case (key, value) =>
UriCompatibility.encodeQuery(key, encoding) + "=" +
UriCompatibility.encodeQuery(value, encoding)
UriCompatibility.encodeBodyPart(key, encoding) + "=" +
UriCompatibility.encodeBodyPart(value, encoding)
}
.mkString("&")

Expand Down
6 changes: 6 additions & 0 deletions core/src/test/scala/sttp/client4/testing/HttpTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,12 @@ trait HttpTest[F[_]]
"multipart" - {
def mp = basicRequest.post(uri"$endpoint/multipart").response(asStringAlways)


"not encode tilde" in {
val part = multipart("v1", Map("k1" -> "v1~", "~k2" -> "v2"))
part.body.show should be("string: k1=v1~&~k2=v2")
}

"send a multipart message" in {
val req = mp.multipartBody(multipart("p1", "v1"), multipart("p2", "v2"))
req.send(backend).toFuture().map { resp =>
Expand Down

0 comments on commit 50c5295

Please sign in to comment.