diff --git a/okhttp/src/main/kotlin/okhttp3/internal/http/CallServerInterceptor.kt b/okhttp/src/main/kotlin/okhttp3/internal/http/CallServerInterceptor.kt index 9c7a60d49d15..324324f17a5e 100644 --- a/okhttp/src/main/kotlin/okhttp3/internal/http/CallServerInterceptor.kt +++ b/okhttp/src/main/kotlin/okhttp3/internal/http/CallServerInterceptor.kt @@ -105,7 +105,7 @@ class CallServerInterceptor(private val forWebSocket: Boolean) : Interceptor { .build() var code = response.code - if (shouldIgnoreAndWaitForRealResponse(code, exchange)) { + while (shouldIgnoreAndWaitForRealResponse(code, exchange)) { responseBuilder = exchange.readResponseHeaders(expectContinue = false)!! if (invokeStartEvent) { exchange.responseHeadersStart() diff --git a/okhttp/src/test/java/okhttp3/CallTest.kt b/okhttp/src/test/java/okhttp3/CallTest.kt index e59e0de7b6ee..a43d76d7dae9 100644 --- a/okhttp/src/test/java/okhttp3/CallTest.kt +++ b/okhttp/src/test/java/okhttp3/CallTest.kt @@ -3234,6 +3234,33 @@ open class CallTest { assertThat(recordedRequest.body.readUtf8()).isEqualTo("abc") } + @Test + fun serverRespondsWithProcessingMultiple() { + server.enqueue( + MockResponse.Builder() + .apply { + repeat(10) { + addInformationalResponse( + MockResponse( + code = HTTP_PROCESSING, + ), + ) + } + } + .build(), + ) + val request = + Request( + url = server.url("/"), + body = "abc".toRequestBody("text/plain".toMediaType()), + ) + executeSynchronously(request) + .assertCode(200) + .assertSuccessful() + val recordedRequest = server.takeRequest() + assertThat(recordedRequest.body.readUtf8()).isEqualTo("abc") + } + @Test fun serverRespondsWithUnsolicited100Continue_HTTP2() { enableProtocol(Protocol.HTTP_2)