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


Java Address类代码示例

本文整理汇总了Java中com.squareup.okhttp.Address的典型用法代码示例。如果您正苦于以下问题:Java Address类的具体用法?Java Address怎么用?Java Address使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Address类属于com.squareup.okhttp包,在下文中一共展示了Address类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RouteSelector

import com.squareup.okhttp.Address; //导入依赖的package包/类
public RouteSelector(Address paramAddress, URI paramURI, OkHttpClient paramOkHttpClient, Request paramRequest)
{
  this.address = paramAddress;
  this.uri = paramURI;
  this.client = paramOkHttpClient;
  this.pool = paramOkHttpClient.connectionPool;
  this.routeDatabase = Internal.instance.routeDatabase(paramOkHttpClient);
  this.network = Internal.instance.network(paramOkHttpClient);
  this.request = paramRequest;
  Proxy localProxy = paramAddress.proxy;
  if (localProxy != null) {
    this.proxies = Collections.singletonList(localProxy);
  }
  for (;;)
  {
    this.nextProxyIndex = 0;
    return;
    this.proxies = new ArrayList();
    List localList = this.client.proxySelector.select(paramURI);
    if (localList != null) {
      this.proxies.addAll(localList);
    }
    this.proxies.removeAll(Collections.singleton(Proxy.NO_PROXY));
    this.proxies.add(Proxy.NO_PROXY);
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:27,代码来源:RouteSelector.java

示例2: singleRoute

import com.squareup.okhttp.Address; //导入依赖的package包/类
@Test public void singleRoute() throws Exception {
  Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator, null,
      protocols);
  RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
      new RouteDatabase());

  assertTrue(routeSelector.hasNext());
  dns.inetAddresses = makeFakeAddresses(255, 1);
  assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
      false);
  dns.assertRequests(uriHost);

  assertFalse(routeSelector.hasNext());
  try {
    routeSelector.next("GET");
    fail();
  } catch (NoSuchElementException expected) {
  }
}
 
开发者ID:xin3liang,项目名称:platform_external_okhttp,代码行数:20,代码来源:RouteSelectorTest.java

示例3: singleRouteReturnsFailedRoute

import com.squareup.okhttp.Address; //导入依赖的package包/类
@Test public void singleRouteReturnsFailedRoute() throws Exception {
  Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator, null,
      protocols);
  RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
      new RouteDatabase());

  assertTrue(routeSelector.hasNext());
  dns.inetAddresses = makeFakeAddresses(255, 1);
  Connection connection = routeSelector.next("GET");
  RouteDatabase routeDatabase = new RouteDatabase();
  routeDatabase.failed(connection.getRoute());
  routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns, routeDatabase);
  assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
      false);
  assertFalse(routeSelector.hasNext());
  try {
    routeSelector.next("GET");
    fail();
  } catch (NoSuchElementException expected) {
  }
}
 
开发者ID:xin3liang,项目名称:platform_external_okhttp,代码行数:22,代码来源:RouteSelectorTest.java

示例4: explicitProxyTriesThatProxiesAddressesOnly

import com.squareup.okhttp.Address; //导入依赖的package包/类
@Test public void explicitProxyTriesThatProxiesAddressesOnly() throws Exception {
  Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator,
      proxyA, protocols);
  RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
      new RouteDatabase());

  assertTrue(routeSelector.hasNext());
  dns.inetAddresses = makeFakeAddresses(255, 2);
  assertConnection(routeSelector.next("GET"), address, proxyA, dns.inetAddresses[0], proxyAPort,
      false);
  assertConnection(routeSelector.next("GET"), address, proxyA, dns.inetAddresses[1], proxyAPort,
      false);

  assertFalse(routeSelector.hasNext());
  dns.assertRequests(proxyAHost);
  proxySelector.assertRequests(); // No proxy selector requests!
}
 
开发者ID:xin3liang,项目名称:platform_external_okhttp,代码行数:18,代码来源:RouteSelectorTest.java

示例5: explicitDirectProxy

import com.squareup.okhttp.Address; //导入依赖的package包/类
@Test public void explicitDirectProxy() throws Exception {
  Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator,
      NO_PROXY, protocols);
  RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
      new RouteDatabase());

  assertTrue(routeSelector.hasNext());
  dns.inetAddresses = makeFakeAddresses(255, 2);
  assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
      false);
  assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[1], uriPort,
      false);

  assertFalse(routeSelector.hasNext());
  dns.assertRequests(uri.getHost());
  proxySelector.assertRequests(); // No proxy selector requests!
}
 
开发者ID:xin3liang,项目名称:platform_external_okhttp,代码行数:18,代码来源:RouteSelectorTest.java

示例6: proxySelectorReturnsNull

import com.squareup.okhttp.Address; //导入依赖的package包/类
@Test public void proxySelectorReturnsNull() throws Exception {
  Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator, null,
      protocols);

  proxySelector.proxies = null;
  RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
      new RouteDatabase());
  proxySelector.assertRequests(uri);

  assertTrue(routeSelector.hasNext());
  dns.inetAddresses = makeFakeAddresses(255, 1);
  assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
      false);
  dns.assertRequests(uriHost);

  assertFalse(routeSelector.hasNext());
}
 
开发者ID:xin3liang,项目名称:platform_external_okhttp,代码行数:18,代码来源:RouteSelectorTest.java

示例7: proxySelectorReturnsNoProxies

import com.squareup.okhttp.Address; //导入依赖的package包/类
@Test public void proxySelectorReturnsNoProxies() throws Exception {
  Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator, null,
      protocols);
  RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
      new RouteDatabase());

  assertTrue(routeSelector.hasNext());
  dns.inetAddresses = makeFakeAddresses(255, 2);
  assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
      false);
  assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[1], uriPort,
      false);

  assertFalse(routeSelector.hasNext());
  dns.assertRequests(uri.getHost());
  proxySelector.assertRequests(uri);
}
 
开发者ID:xin3liang,项目名称:platform_external_okhttp,代码行数:18,代码来源:RouteSelectorTest.java

示例8: proxySelectorDirectConnectionsAreSkipped

import com.squareup.okhttp.Address; //导入依赖的package包/类
@Test public void proxySelectorDirectConnectionsAreSkipped() throws Exception {
  Address address = new Address(uriHost, uriPort, socketFactory, null, null, authenticator, null,
      protocols);

  proxySelector.proxies.add(NO_PROXY);
  RouteSelector routeSelector = new RouteSelector(address, uri, proxySelector, pool, dns,
      new RouteDatabase());
  proxySelector.assertRequests(uri);

  // Only the origin server will be attempted.
  assertTrue(routeSelector.hasNext());
  dns.inetAddresses = makeFakeAddresses(255, 1);
  assertConnection(routeSelector.next("GET"), address, NO_PROXY, dns.inetAddresses[0], uriPort,
      false);
  dns.assertRequests(uriHost);

  assertFalse(routeSelector.hasNext());
}
 
开发者ID:xin3liang,项目名称:platform_external_okhttp,代码行数:19,代码来源:RouteSelectorTest.java

示例9: createAddress

import com.squareup.okhttp.Address; //导入依赖的package包/类
private static Address createAddress(OkHttpClient client, Request request) {
    SSLSocketFactory sslSocketFactory = null;
    HostnameVerifier hostnameVerifier = null;
    CertificatePinner certificatePinner = null;
    if (request.isHttps()) {
        sslSocketFactory = client.getSslSocketFactory();
        hostnameVerifier = client.getHostnameVerifier();
        certificatePinner = client.getCertificatePinner();
    }
    return new Address(request.httpUrl().host(), request.httpUrl().port(), client.getDns(),
            client.getSocketFactory(), sslSocketFactory, hostnameVerifier, certificatePinner, client.getAuthenticator(), client.getProxy(), client.getProtocols(), client.getConnectionSpecs(), client.getProxySelector());
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:HttpEngine.java

示例10: RouteSelector

import com.squareup.okhttp.Address; //导入依赖的package包/类
public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
    Dns dns, RouteDatabase routeDatabase) {
  this.address = address;
  this.uri = uri;
  this.proxySelector = proxySelector;
  this.pool = pool;
  this.dns = dns;
  this.routeDatabase = routeDatabase;
  this.postponedRoutes = new LinkedList<Route>();

  resetNextProxy(uri, address.getProxy());
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:13,代码来源:RouteSelector.java

示例11: connect

import com.squareup.okhttp.Address; //导入依赖的package包/类
/** Connect to the origin server either directly or via a proxy. */
protected final void connect() throws IOException {
  if (connection != null) {
    return;
  }
  if (routeSelector == null) {
    String uriHost = uri.getHost();
    if (uriHost == null) {
      throw new UnknownHostException(uri.toString());
    }
    SSLSocketFactory sslSocketFactory = null;
    HostnameVerifier hostnameVerifier = null;
    if (uri.getScheme().equalsIgnoreCase("https")) {
      sslSocketFactory = client.getSslSocketFactory();
      hostnameVerifier = client.getHostnameVerifier();
    }
    Address address = new Address(uriHost, getEffectivePort(uri), sslSocketFactory,
        hostnameVerifier, client.getAuthenticator(), client.getProxy(), client.getTransports());
    routeSelector = new RouteSelector(address, uri, client.getProxySelector(),
        client.getConnectionPool(), Dns.DEFAULT, client.getRoutesDatabase());
  }
  connection = routeSelector.next(method);
  if (!connection.isConnected()) {
    connection.connect(client.getConnectTimeout(), client.getReadTimeout(), getTunnelConfig());
    client.getConnectionPool().maybeShare(connection);
    client.getRoutesDatabase().connected(connection.getRoute());
  } else if (!connection.isSpdy()) {
      connection.updateReadTimeout(client.getReadTimeout());
  }
  connected(connection);
  if (connection.getRoute().getProxy() != client.getProxy()) {
    // Update the request line if the proxy changed; it may need a host name.
    requestHeaders.getHeaders().setRequestLine(getRequestLine());
  }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:36,代码来源:HttpEngine.java

示例12: proceed

import com.squareup.okhttp.Address; //导入依赖的package包/类
public final Response proceed(Request paramRequest)
  throws IOException
{
  this.calls = (1 + this.calls);
  if (this.index > 0)
  {
    Interceptor localInterceptor2 = (Interceptor)HttpEngine.this.client.networkInterceptors.get(-1 + this.index);
    Address localAddress = HttpEngine.this.connection.route.address;
    if ((!paramRequest.url().getHost().equals(localAddress.uriHost)) || (Util.getEffectivePort(paramRequest.url()) != localAddress.uriPort)) {
      throw new IllegalStateException("network interceptor " + localInterceptor2 + " must retain the same host and port");
    }
    if (this.calls > 1) {
      throw new IllegalStateException("network interceptor " + localInterceptor2 + " must call proceed() exactly once");
    }
  }
  Response localResponse;
  if (this.index < HttpEngine.this.client.networkInterceptors.size())
  {
    NetworkInterceptorChain localNetworkInterceptorChain = new NetworkInterceptorChain(HttpEngine.this, 1 + this.index, paramRequest);
    Interceptor localInterceptor1 = (Interceptor)HttpEngine.this.client.networkInterceptors.get(this.index);
    localResponse = localInterceptor1.intercept(localNetworkInterceptorChain);
    if (localNetworkInterceptorChain.calls != 1) {
      throw new IllegalStateException("network interceptor " + localInterceptor1 + " must call proceed() exactly once");
    }
  }
  else
  {
    HttpEngine.this.transport.writeRequestHeaders(paramRequest);
    if ((HttpEngine.this.permitsRequestBody()) && (paramRequest.body != null))
    {
      BufferedSink localBufferedSink = Okio.buffer(HttpEngine.this.transport.createRequestBody(paramRequest, paramRequest.body.contentLength()));
      paramRequest.body.writeTo(localBufferedSink);
      localBufferedSink.close();
    }
    localResponse = HttpEngine.this.readNetworkResponse();
  }
  return localResponse;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:39,代码来源:HttpEngine.java


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