Skip to content

Commit 0ceafad

Browse files
authored
KTOR-8687 Fix missing \r\n in CIO Expect-Continue response (#5019)
1 parent 92266d5 commit 0ceafad

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

ktor-server/ktor-server-cio/common/src/io/ktor/server/cio/CIOApplicationEngine.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public class CIOApplicationEngine(
120120
handleRequest(request)
121121
}
122122
}
123+
123124
else -> {
124125
val settings = HttpServerSettings(
125126
host = connectorSpec.host,
@@ -136,7 +137,7 @@ public class CIOApplicationEngine(
136137
}
137138

138139
private fun addHandlerForExpectedHeader(output: ByteWriteChannel, call: CIOApplicationCall) {
139-
val continueResponse = "HTTP/1.1 100 Continue\r\n"
140+
val continueResponse = "HTTP/1.1 100 Continue$CRLF$CRLF"
140141
val expectHeaderValue = "100-continue"
141142

142143
val expectedHeaderPhase = PipelinePhase("ExpectedHeaderPhase")
@@ -249,3 +250,5 @@ public class CIOApplicationEngine(
249250
}
250251
}
251252
}
253+
254+
private const val CRLF = "\r\n"

ktor-server/ktor-server-cio/common/test/io/ktor/tests/server/cio/CIOEngineTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class CIOHttpServerTest : HttpServerCommonTestSuite<CIOApplicationEngine, CIOApp
9292
writePostHeaders(writeChannel, body.length)
9393
val continueResponse = readChannel.readUTF8Line()
9494
assertEquals("HTTP/1.1 100 Continue", continueResponse)
95+
assertTrue { readChannel.readUTF8Line()?.isEmpty() ?: false }
9596

9697
writePostBody(writeChannel, body)
9798
val response = readAvailable(readChannel)

0 commit comments

Comments
 (0)