1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-12 10:23:16 +03:00

Add test that covers MockWebServer and URLConnection with 100-Continue (#8995)

This commit is contained in:
Yuri Schimke
2025-08-03 23:38:00 +01:00
committed by GitHub
parent 8c3a3c98f5
commit a5f8e4e5cb

View File

@@ -654,6 +654,28 @@ class MockWebServerTest {
assertThat(request.body?.utf8()).isEqualTo("request")
}
@Test
fun http100ContinueChunkedStreaming() {
server.enqueue(
MockResponse
.Builder()
.body("response")
.add100Continue()
.build(),
)
val url = server.url("/").toUrl()
val connection = url.openConnection() as HttpURLConnection
connection.doOutput = true
connection.setRequestProperty("Expect", "100-Continue")
connection.setChunkedStreamingMode(0)
connection.outputStream.write("request".toByteArray(UTF_8))
val inputStream = connection.inputStream
val reader = BufferedReader(InputStreamReader(inputStream, UTF_8))
assertThat(reader.readLine()).isEqualTo("response")
val request = server.takeRequest()
assertThat(request.body?.utf8()).isEqualTo("request")
}
@Test
fun multiple1xxResponses() {
server.enqueue(