diff options
author | Neil Fuller <nfuller@google.com> | 2015-08-07 10:14:41 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-08-07 10:14:41 +0000 |
commit | 809c1a68128f6ad97951be6525205488fc4f1d4e (patch) | |
tree | 0614dfdd0d5b2e53e6b963d47eb34e710095f2ca /luni/src/test/java | |
parent | 7485d2ceef133bd12811308c57062593b65bbb02 (diff) | |
parent | 236dcb7781bbacb52f9a0834198ca99379c87a84 (diff) | |
download | libcore-809c1a68128f6ad97951be6525205488fc4f1d4e.zip libcore-809c1a68128f6ad97951be6525205488fc4f1d4e.tar.gz libcore-809c1a68128f6ad97951be6525205488fc4f1d4e.tar.bz2 |
am 236dcb77: am cd07c28b: am 8fd977f6: am bebe6fa7: Merge "Revert "Revert "Changes associated with an OkHttp bad proxy response fix""" into lollipop-mr1-cts-dev
* commit '236dcb7781bbacb52f9a0834198ca99379c87a84':
Revert "Revert "Changes associated with an OkHttp bad proxy response fix""
Diffstat (limited to 'luni/src/test/java')
-rw-r--r-- | luni/src/test/java/libcore/java/net/URLConnectionTest.java | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/luni/src/test/java/libcore/java/net/URLConnectionTest.java b/luni/src/test/java/libcore/java/net/URLConnectionTest.java index 223bb7b..3f831e0 100644 --- a/luni/src/test/java/libcore/java/net/URLConnectionTest.java +++ b/luni/src/test/java/libcore/java/net/URLConnectionTest.java @@ -646,42 +646,32 @@ public final class URLConnectionTest extends AbstractResourceLeakageDetectorTest * Tolerate bad https proxy response when using HttpResponseCache. http://b/6754912 */ public void testConnectViaHttpProxyToHttpsUsingBadProxyAndHttpResponseCache() throws Exception { - ProxyConfig proxyConfig = ProxyConfig.PROXY_SYSTEM_PROPERTY; - TestSSLContext testSSLContext = TestSSLContext.create(); initResponseCache(); server.useHttps(testSSLContext.serverContext.getSocketFactory(), true); + + // The inclusion of a body in the response to the CONNECT is key to reproducing b/6754912. MockResponse badProxyResponse = new MockResponse() .setSocketPolicy(SocketPolicy.UPGRADE_TO_SSL_AT_END) .clearHeaders() - .setBody("bogus proxy connect response content"); // Key to reproducing b/6754912 + .setBody("bogus proxy connect response content"); - // We enqueue the bad response twice because the connection will - // be retried with TLS_MODE_COMPATIBLE after the first connection - // fails. - server.enqueue(badProxyResponse); server.enqueue(badProxyResponse); + server.enqueue(new MockResponse().setBody("response")); server.play(); URL url = new URL("https://android.com/foo"); + ProxyConfig proxyConfig = ProxyConfig.PROXY_SYSTEM_PROPERTY; HttpsURLConnection connection = (HttpsURLConnection) proxyConfig.connect(server, url); connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory()); - - try { - connection.connect(); - fail(); - } catch (SSLHandshakeException expected) { - // Thrown when the connect causes SSLSocket.startHandshake() to throw - // when it sees the "bogus proxy connect response content" - // instead of a ServerHello handshake message. - } + connection.setHostnameVerifier(new RecordingHostnameVerifier()); + assertContent("response", connection); RecordedRequest connect = server.takeRequest(); - assertEquals("Connect line failure on proxy", - "CONNECT android.com:443 HTTP/1.1", connect.getRequestLine()); + assertEquals("CONNECT android.com:443 HTTP/1.1", connect.getRequestLine()); assertContains(connect.getHeaders(), "Host: android.com"); } |