File tree Expand file tree Collapse file tree
ktor-client/ktor-client-cio/jvm/test/io/ktor/client/engine/cio Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2014-2026 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+ */
4+
5+ package io.ktor.client.engine.cio
6+
7+ import io.ktor.client.*
8+ import io.ktor.client.request.*
9+ import io.ktor.http.*
10+ import kotlinx.coroutines.test.runTest
11+ import java.net.ServerSocket
12+ import java.net.SocketException
13+ import kotlin.concurrent.thread
14+ import kotlin.test.Test
15+ import kotlin.test.assertEquals
16+
17+ class CookieHeaderCaseTest {
18+
19+ @Test
20+ fun `CIO preserves Set-Cookie headers regardless of case` () = runTest {
21+ HttpClient (CIO ).use { client ->
22+ ServerSocket (0 ).use { server ->
23+ val thread = thread {
24+ try {
25+ server.accept().use { socket ->
26+ socket.getOutputStream().let { out ->
27+ out .write(
28+ (
29+ " HTTP/1.1 200 OK\r\n " +
30+ " Content-Length: 0\r\n " +
31+ " Set-Cookie: first=1\r\n " +
32+ " set-cookie: second=2\r\n " +
33+ " \r\n "
34+ ).toByteArray()
35+ )
36+ out .flush()
37+ }
38+ }
39+ } catch (_: SocketException ) {
40+ }
41+ }
42+
43+ val response = client.get(" http://localhost:${server.localPort} /" )
44+ assertEquals(
45+ listOf (" first=1" , " second=2" ),
46+ response.headers.getAll(HttpHeaders .SetCookie )
47+ )
48+ thread.join()
49+ }
50+ }
51+ }
52+ }
You can’t perform that action at this time.
0 commit comments