Skip to content

Commit

Permalink
KTOR-5814 Don't reparse query parameters when sending a request with … (
Browse files Browse the repository at this point in the history
#3622)

* KTOR-5814 Don't reparse query parameters when sending a request with Android engine
* KTOR-5814 Fix formatting
  • Loading branch information
Stexxe authored May 29, 2023
1 parent 180f9b4 commit 85d4f6e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/test/server/tests/Content.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import test.server.*
internal fun Application.contentTestServer() {
routing {
route("/content") {
get("/uri") {
call.respondText { call.request.local.uri }
}

get("/empty") {
call.respond("")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class AndroidClientEngine(override val config: AndroidEngineConfig) : Htt

val requestTime = GMTDate()

val url: String = URLBuilder().takeFrom(data.url).buildString()
val url: String = data.url.toString()
val outgoingContent: OutgoingContent = data.body
val contentLength: Long? = data.headers[HttpHeaders.ContentLength]?.toLong()
?: outgoingContent.contentLength
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2014-2023 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.client.tests

import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.client.tests.utils.*
import io.ktor.http.*
import kotlin.test.*

class QueryTest : ClientLoader() {
@Test
fun queryParametersArentModified() = clientTests {
test { client ->
val result = client.get {
url {
encodedParameters.apply {
url.encodedParameters.appendAll("", emptyList())
url.takeFrom("$TEST_SERVER/content/uri?Expires")
}
}
}.bodyAsText()
assertEquals("/content/uri?&Expires", result)
}
}
}

0 comments on commit 85d4f6e

Please sign in to comment.