Skip to content

Commit

Permalink
KTOR-5868 Fix the delimiter for a Cookie name-value pairs (#3739)
Browse files Browse the repository at this point in the history
(cherry picked from commit 67e4f4e)
  • Loading branch information
marychatte committed Aug 30, 2023
1 parent d17b3d9 commit ce50296
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public fun mergeHeaders(
block(key, value)
}
} else {
block(key, values.joinToString(","))
val separator = if (HttpHeaders.Cookie == key) "; " else ","
block(key, values.joinToString(separator))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,17 @@ class CookiesTest : ClientLoader() {
}
}

@Test
fun testSeparatedBySemicolon() = clientTests(listOf("Js")) {
test { client ->
client.get("$TEST_HOST/encoded") {
cookie("firstCookie", "first")
header("Cookie", "secondCookie=second")
}.bodyAsText().also {
assertEquals("firstCookie=first; secondCookie=second", it)
}
}
}

private suspend fun HttpClient.getId() = cookies(hostname)["id"]!!.value.toInt()
}

0 comments on commit ce50296

Please sign in to comment.