Skip to content

Commit 7ef4fb4

Browse files
authored
Add another test for headers' size limit (#8584)
1 parent 27521ef commit 7ef4fb4

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

okhttp/src/test/java/okhttp3/CallTest.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,8 +2619,8 @@ open class CallTest {
26192619
}
26202620

26212621
@Test
2622-
fun httpWithExcessiveHeaders() {
2623-
val longLine = "HTTP/1.1 200 " + stringFill('O', 256 * 1024) + "K"
2622+
fun httpWithExcessiveStatusLine() {
2623+
val longLine = "HTTP/1.1 200 " + "O".repeat(256 * 1024) + "K"
26242624
server.protocols = listOf(Protocol.HTTP_1_1)
26252625
server.enqueue(
26262626
MockResponse.Builder()
@@ -2629,16 +2629,21 @@ open class CallTest {
26292629
.build(),
26302630
)
26312631
executeSynchronously("/")
2632-
.assertFailureMatches(".*unexpected end of stream on " + server.url("/").redact())
2632+
.assertFailureMatches(".*unexpected end of stream on ${server.url("/").redact()}")
26332633
}
26342634

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

26442649
@Test

0 commit comments

Comments
 (0)