本文整理汇总了Java中okhttp3.internal.http.RecordingProxySelector类的典型用法代码示例。如果您正苦于以下问题:Java RecordingProxySelector类的具体用法?Java RecordingProxySelector怎么用?Java RecordingProxySelector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RecordingProxySelector类属于okhttp3.internal.http包,在下文中一共展示了RecordingProxySelector类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectTimeoutsAttemptsAlternateRoute
import okhttp3.internal.http.RecordingProxySelector; //导入依赖的package包/类
/**
* Make a request with two routes. The first route will time out because it's connecting to a
* special address that never connects. The automatic retry will succeed.
*/
@Test public void connectTimeoutsAttemptsAlternateRoute() throws Exception {
InetSocketAddress unreachableAddress = new InetSocketAddress("10.255.255.1", 8080);
RecordingProxySelector proxySelector = new RecordingProxySelector();
proxySelector.proxies.add(new Proxy(Proxy.Type.HTTP, unreachableAddress));
proxySelector.proxies.add(server.toProxyAddress());
server.enqueue(new MockResponse()
.setBody("success!"));
client = client.newBuilder()
.proxySelector(proxySelector)
.readTimeout(100, TimeUnit.MILLISECONDS)
.connectTimeout(100, TimeUnit.MILLISECONDS)
.build();
Request request = new Request.Builder().url("http://android.com/").build();
executeSynchronously(request)
.assertCode(200)
.assertBody("success!");
}
示例2: readTimeoutFails
import okhttp3.internal.http.RecordingProxySelector; //导入依赖的package包/类
/**
* Make a request with two routes. The first route will fail because the null server connects but
* never responds. The manual retry will succeed.
*/
@Test public void readTimeoutFails() throws Exception {
InetSocketAddress nullServerAddress = startNullServer();
RecordingProxySelector proxySelector = new RecordingProxySelector();
proxySelector.proxies.add(new Proxy(Proxy.Type.HTTP, nullServerAddress));
proxySelector.proxies.add(server.toProxyAddress());
server.enqueue(new MockResponse()
.setBody("success!"));
client = client.newBuilder()
.proxySelector(proxySelector)
.readTimeout(100, TimeUnit.MILLISECONDS)
.build();
Request request = new Request.Builder().url("http://android.com/").build();
executeSynchronously(request)
.assertFailure(SocketTimeoutException.class);
executeSynchronously(request)
.assertCode(200)
.assertBody("success!");
}
示例3: connectTimeoutsAttemptsAlternateRoute
import okhttp3.internal.http.RecordingProxySelector; //导入依赖的package包/类
/**
* Make a request with two routes. The first route will time out because it's connecting to a
* special address that never connects. The automatic retry will succeed.
*/
@Test public void connectTimeoutsAttemptsAlternateRoute() throws Exception {
RecordingProxySelector proxySelector = new RecordingProxySelector();
proxySelector.proxies.add(new Proxy(Proxy.Type.HTTP, TestUtil.UNREACHABLE_ADDRESS));
proxySelector.proxies.add(server.toProxyAddress());
server.enqueue(new MockResponse()
.setBody("success!"));
client = client.newBuilder()
.proxySelector(proxySelector)
.readTimeout(100, TimeUnit.MILLISECONDS)
.connectTimeout(100, TimeUnit.MILLISECONDS)
.build();
Request request = new Request.Builder().url("http://android.com/").build();
executeSynchronously(request)
.assertCode(200)
.assertBody("success!");
}
示例4: readTimeoutFails
import okhttp3.internal.http.RecordingProxySelector; //导入依赖的package包/类
/**
* Make a request with two routes. The first route will fail because the null server connects but
* never responds. The manual retry will succeed.
*/
@Test public void readTimeoutFails() throws Exception {
nullServer.start();
RecordingProxySelector proxySelector = new RecordingProxySelector();
proxySelector.proxies.add(new Proxy(Proxy.Type.HTTP, nullServer.address()));
proxySelector.proxies.add(server.toProxyAddress());
server.enqueue(new MockResponse()
.setBody("success!"));
client = client.newBuilder()
.proxySelector(proxySelector)
.readTimeout(100, TimeUnit.MILLISECONDS)
.build();
Request request = new Request.Builder().url("http://android.com/").build();
executeSynchronously(request)
.assertFailure(SocketTimeoutException.class);
executeSynchronously(request)
.assertCode(200)
.assertBody("success!");
}
示例5: connectTimeoutsAttemptsAlternateRoute
import okhttp3.internal.http.RecordingProxySelector; //导入依赖的package包/类
/**
* Make a request with two routes. The first route will time out because it's connecting via a
* null proxy server. The second will succeed.
*/
@Test public void connectTimeoutsAttemptsAlternateRoute() throws Exception {
InetSocketAddress nullServerAddress = startNullServer();
RecordingProxySelector proxySelector = new RecordingProxySelector();
proxySelector.proxies.add(new Proxy(Proxy.Type.HTTP, nullServerAddress));
proxySelector.proxies.add(server.toProxyAddress());
server.enqueue(new MockResponse()
.setBody("success!"));
client = client.newBuilder()
.proxySelector(proxySelector)
.readTimeout(100, TimeUnit.MILLISECONDS)
.build();
Request request = new Request.Builder().url("http://android.com/").build();
executeSynchronously(request)
.assertCode(200)
.assertBody("success!");
}
示例6: differentProxySelectorsAreDifferent
import okhttp3.internal.http.RecordingProxySelector; //导入依赖的package包/类
@Test public void differentProxySelectorsAreDifferent() throws Exception {
Address a = new Address("square.com", 80, dns, socketFactory, null, null, null,
authenticator, null, protocols, connectionSpecs, new RecordingProxySelector());
Address b = new Address("square.com", 80, dns, socketFactory, null, null, null,
authenticator, null, protocols, connectionSpecs, new RecordingProxySelector());
assertFalse(a.equals(b));
}