use of okhttp3.RecordingHostnameVerifier in project okhttp by square.
the class URLConnectionTest method sslFallbackNotUsedWhenRecycledConnectionFails.
/**
* When a pooled connection fails, don't blame the route. Otherwise pooled connection failures can
* cause unnecessary SSL fallbacks.
*
* https://github.com/square/okhttp/issues/515
*/
@Test
public void sslFallbackNotUsedWhenRecycledConnectionFails() throws Exception {
server.useHttps(sslClient.socketFactory, false);
server.enqueue(new MockResponse().setBody("abc").setSocketPolicy(DISCONNECT_AT_END));
server.enqueue(new MockResponse().setBody("def"));
urlFactory.setClient(urlFactory.client().newBuilder().hostnameVerifier(new RecordingHostnameVerifier()).sslSocketFactory(suppressTlsFallbackClientSocketFactory(), sslClient.trustManager).build());
assertContent("abc", urlFactory.open(server.url("/").url()));
// Give the server time to disconnect.
Thread.sleep(500);
assertContent("def", urlFactory.open(server.url("/").url()));
Set<TlsVersion> tlsVersions = // v1.2 on OpenJDK 8.
EnumSet.of(TlsVersion.TLS_1_0, TlsVersion.TLS_1_2);
RecordedRequest request1 = server.takeRequest();
assertTrue(tlsVersions.contains(request1.getTlsVersion()));
RecordedRequest request2 = server.takeRequest();
assertTrue(tlsVersions.contains(request2.getTlsVersion()));
}
use of okhttp3.RecordingHostnameVerifier in project okhttp by square.
the class WebSocketHttpTest method httpsScheme.
@Test
public void httpsScheme() throws IOException {
webServer.useHttps(sslClient.socketFactory, false);
client = client.newBuilder().sslSocketFactory(sslClient.socketFactory, sslClient.trustManager).hostnameVerifier(new RecordingHostnameVerifier()).build();
websocketScheme("https");
}
Aggregations