Java 类com.squareup.okhttp.Address 实例源码

项目:FMTech    文件:RouteSelector.java   
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);
  }
}
项目:platform_external_okhttp    文件:RouteSelectorTest.java   
@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) {
  }
}
项目:platform_external_okhttp    文件:RouteSelectorTest.java   
@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) {
  }
}
项目:platform_external_okhttp    文件:RouteSelectorTest.java   
@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!
}
项目:platform_external_okhttp    文件:RouteSelectorTest.java   
@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!
}
项目:platform_external_okhttp    文件:RouteSelectorTest.java   
@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());
}
项目:platform_external_okhttp    文件:RouteSelectorTest.java   
@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);
}
项目:platform_external_okhttp    文件:RouteSelectorTest.java   
@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());
}
项目:boohee_v5.6    文件:HttpEngine.java   
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());
}
项目:LoRaWAN-Smart-Parking    文件:RouteSelector.java   
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());
}
项目:LoRaWAN-Smart-Parking    文件:HttpEngine.java   
/** 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());
  }
}
项目:LoRaWAN-Smart-Parking    文件:RouteSelector.java   
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());
}
项目:LoRaWAN-Smart-Parking    文件:HttpEngine.java   
/** 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());
  }
}
项目:smart-mirror-app    文件:RouteSelector.java   
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());
}
项目:smart-mirror-app    文件:HttpEngine.java   
/** 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());
  }
}
项目:cordova-plugin-background-mode    文件:RouteSelector.java   
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());
}
项目:cordova-plugin-background-mode    文件:HttpEngine.java   
/** 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());
  }
}
项目:multirotorstuff-vtx-calc    文件:RouteSelector.java   
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());
}
项目:multirotorstuff-vtx-calc    文件:HttpEngine.java   
/** 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());
  }
}
项目:FMTech    文件:HttpEngine.java   
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;
}
项目:L.TileLayer.Cordova    文件:RouteSelector.java   
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());
}
项目:L.TileLayer.Cordova    文件:HttpEngine.java   
/** 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());
  }
}
项目:cordova-android-tv    文件:RouteSelector.java   
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());
}
项目:cordova-android-tv    文件:HttpEngine.java   
/** 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());
  }
}
项目:Cordova-Locale-Plugin    文件:RouteSelector.java   
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());
}
项目:Cordova-Locale-Plugin    文件:HttpEngine.java   
/** 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());
  }
}
项目:pubnub-rpi-smart-parking    文件:RouteSelector.java   
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());
}
项目:pubnub-rpi-smart-parking    文件:HttpEngine.java   
/** 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());
  }
}
项目:IoTgo_Android_App    文件:RouteSelector.java   
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());
}
项目:IoTgo_Android_App    文件:HttpEngine.java   
/** 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());
  }
}
项目:CanDoVS2015    文件:RouteSelector.java   
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());
}
项目:CanDoVS2015    文件:HttpEngine.java   
/** 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());
  }
}
项目:krakn    文件:RouteSelector.java   
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());
}
项目:krakn    文件:HttpEngine.java   
/** 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());
  }
}
项目:krakn    文件:RouteSelector.java   
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());
}
项目:krakn    文件:HttpEngine.java   
/** 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());
  }
}
项目:krakn    文件:RouteSelector.java   
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());
}
项目:krakn    文件:HttpEngine.java   
/** 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());
  }
}
项目:krakn    文件:RouteSelector.java   
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());
}
项目:krakn    文件:HttpEngine.java   
/** 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());
  }
}