当前位置: 首页>>代码示例>>Java>>正文


Java RecordingProxySelector类代码示例

本文整理汇总了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!");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:CallTest.java

示例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!");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:CallTest.java

示例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!");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:CallTest.java

示例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!");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:CallTest.java

示例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!");
}
 
开发者ID:lizhangqu,项目名称:PriorityOkHttp,代码行数:25,代码来源:CallTest.java

示例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));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:AddressTest.java


注:本文中的okhttp3.internal.http.RecordingProxySelector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。