diff --git a/okhttp/src/test/java/okhttp3/CallTest.kt b/okhttp/src/test/java/okhttp3/CallTest.kt index a43d76d7dae9..47d1dc91d4d3 100644 --- a/okhttp/src/test/java/okhttp3/CallTest.kt +++ b/okhttp/src/test/java/okhttp3/CallTest.kt @@ -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() @@ -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