Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions okhttp/src/test/java/okhttp3/CallTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2619,8 +2619,8 @@ open class CallTest {
}

@Test
fun httpWithExcessiveHeaders() {
val longLine = "HTTP/1.1 200 " + stringFill('O', 256 * 1024) + "K"
fun httpWithExcessiveStatusLine() {
val longLine = "HTTP/1.1 200 " + "O".repeat(256 * 1024) + "K"
server.protocols = listOf(Protocol.HTTP_1_1)
server.enqueue(
MockResponse.Builder()
Expand All @@ -2629,16 +2629,21 @@ open class CallTest {
.build(),
)
executeSynchronously("/")
.assertFailureMatches(".*unexpected end of stream on " + server.url("/").redact())
.assertFailureMatches(".*unexpected end of stream on ${server.url("/").redact()}")
}

private fun stringFill(
fillChar: Char,
length: Int,
): String {
val value = CharArray(length)
Arrays.fill(value, fillChar)
return String(value)
@Test
fun httpWithExcessiveHeaders() {
server.protocols = listOf(Protocol.HTTP_1_1)
server.enqueue(
MockResponse.Builder()
.addHeader("Set-Cookie", "a=${"A".repeat(255 * 1024)}")
.addHeader("Set-Cookie", "b=${"B".repeat(1 * 1024)}")
.body("I'm not even supposed to be here today.")
.build(),
)
executeSynchronously("/")
.assertFailureMatches(".*unexpected end of stream on ${server.url("/").redact()}")
}

@Test
Expand Down