From ab3ff2d95f1bfddd225a78b850d673a996880b02 Mon Sep 17 00:00:00 2001 From: Amir Livneh Date: Sat, 13 Apr 2019 11:00:58 -0400 Subject: [PATCH] Test proxy disconnecting before sending response headers Reproduces https://github.com/square/okhttp/issues/4915 --- okhttp/src/test/java/okhttp3/CallTest.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/okhttp/src/test/java/okhttp3/CallTest.java b/okhttp/src/test/java/okhttp3/CallTest.java index 081e41857..0463d461f 100644 --- a/okhttp/src/test/java/okhttp3/CallTest.java +++ b/okhttp/src/test/java/okhttp3/CallTest.java @@ -3231,6 +3231,29 @@ public final class CallTest { assertThat(challengeSchemes).containsExactly("OkHttp-Preemptive", "Basic"); } + /** https://github.com/square/okhttp/issues/4915 */ + @Test @Ignore public void proxyDisconnectsAfterRequest() throws Exception { + server.useHttps(handshakeCertificates.sslSocketFactory(), true); + server.enqueue(new MockResponse() + .setSocketPolicy(SocketPolicy.DISCONNECT_AFTER_REQUEST)); + + client = client.newBuilder() + .sslSocketFactory( + handshakeCertificates.sslSocketFactory(), handshakeCertificates.trustManager()) + .proxy(server.toProxyAddress()) + .build(); + + Request request = new Request.Builder() + .url(server.url("/")) + .build(); + + try { + Response response = client.newCall(request).execute(); + fail(); + } catch (IOException expected) { + } + } + @Test public void interceptorGetsHttp2() throws Exception { platform.assumeHttp2Support();