Java Code Examples for java.net.ResponseCache

The following are top voted examples for showing how to use java.net.ResponseCache. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: LoRaWAN-Smart-Parking   File: OkHttpClient.java   Source Code and License 7 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 2
Project: LoRaWAN-Smart-Parking   File: OkHttpClient.java   Source Code and License 7 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 3
Project: GitHub   File: CacheAdapterTest.java   Source Code and License 6 votes vote down vote up
@Test public void get_httpGet() throws Exception {
  final URL serverUrl = configureServer(new MockResponse());
  assertEquals("http", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheResponse get(
        URI uri, String method, Map<String, List<String>> headers) throws IOException {
      try {
        assertEquals(toUri(serverUrl), uri);
        assertEquals("GET", method);
        assertTrue("Arbitrary standard header not present", headers.containsKey("User-Agent"));
        assertEquals(Collections.singletonList("value1"), headers.get("key1"));
        return null;
      } catch (Throwable t) {
        throw new IOException("unexpected cache failure", t);
      }
    }
  };
  setInternalCache(new CacheAdapter(responseCache));

  connection = new OkUrlFactory(client).open(serverUrl);
  connection.setRequestProperty("key1", "value1");

  executeGet(connection);
}
 
Example 4
Project: GitHub   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheHitWithoutVary() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("FAIL"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection2));
}
 
Example 5
Project: GitHub   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVaryAcceptEncoding() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: Accept-Encoding")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("B", readAscii(connection2));
}
 
Example 6
Project: GitHub   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVary() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: Accept-Language")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  connection.setRequestProperty("Accept-Language", "en-US");
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("B", readAscii(connection2));
}
 
Example 7
Project: GitHub   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVaryAsterisk() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: *")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("B", readAscii(connection2));
}
 
Example 8
Project: GitHub   File: CacheAdapterTest.java   Source Code and License 6 votes vote down vote up
@Test public void get_httpGet() throws Exception {
  final URL serverUrl = configureServer(new MockResponse());
  assertEquals("http", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheResponse get(
        URI uri, String method, Map<String, List<String>> headers) throws IOException {
      try {
        assertEquals(toUri(serverUrl), uri);
        assertEquals("GET", method);
        assertTrue("Arbitrary standard header not present", headers.containsKey("User-Agent"));
        assertEquals(Collections.singletonList("value1"), headers.get("key1"));
        return null;
      } catch (Throwable t) {
        throw new IOException("unexpected cache failure", t);
      }
    }
  };
  setInternalCache(new CacheAdapter(responseCache));

  connection = new OkUrlFactory(client).open(serverUrl);
  connection.setRequestProperty("key1", "value1");

  executeGet(connection);
}
 
Example 9
Project: GitHub   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheHitWithoutVary() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("FAIL"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection2));
}
 
Example 10
Project: GitHub   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVaryAcceptEncoding() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: Accept-Encoding")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("B", readAscii(connection2));
}
 
Example 11
Project: GitHub   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVary() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: Accept-Language")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  connection.setRequestProperty("Accept-Language", "en-US");
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("B", readAscii(connection2));
}
 
Example 12
Project: GitHub   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVaryAsterisk() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: *")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("B", readAscii(connection2));
}
 
Example 13
Project: PriorityOkHttp   File: CacheAdapterTest.java   Source Code and License 6 votes vote down vote up
@Test public void get_httpGet() throws Exception {
  final URL serverUrl = configureServer(new MockResponse());
  assertEquals("http", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheResponse get(
        URI uri, String method, Map<String, List<String>> headers) throws IOException {
      assertEquals(toUri(serverUrl), uri);
      assertEquals("GET", method);
      assertTrue("Arbitrary standard header not present", headers.containsKey("User-Agent"));
      assertEquals(Collections.singletonList("value1"), headers.get("key1"));
      return null;
    }
  };
  setInternalCache(new CacheAdapter(responseCache));

  connection = new OkUrlFactory(client).open(serverUrl);
  connection.setRequestProperty("key1", "value1");

  executeGet(connection);
}
 
Example 14
Project: PriorityOkHttp   File: CacheAdapterTest.java   Source Code and License 6 votes vote down vote up
@Test public void get_httpsGet() throws Exception {
  final URL serverUrl = configureHttpsServer(new MockResponse());
  assertEquals("https", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheResponse get(URI uri, String method, Map<String, List<String>> headers)
        throws IOException {
      assertEquals("https", uri.getScheme());
      assertEquals(toUri(serverUrl), uri);
      assertEquals("GET", method);
      assertTrue("Arbitrary standard header not present", headers.containsKey("User-Agent"));
      assertEquals(Collections.singletonList("value1"), headers.get("key1"));
      return null;
    }
  };
  setInternalCache(new CacheAdapter(responseCache));
  client = client.newBuilder()
      .sslSocketFactory(sslContext.getSocketFactory())
      .hostnameVerifier(hostnameVerifier)
      .build();

  connection = new OkUrlFactory(client).open(serverUrl);
  connection.setRequestProperty("key1", "value1");

  executeGet(connection);
}
 
Example 15
Project: PriorityOkHttp   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheHitWithoutVary() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("FAIL"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof HttpURLConnectionImpl);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof HttpURLConnectionImpl);
  assertEquals("A", readAscii(connection2));
}
 
Example 16
Project: PriorityOkHttp   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVaryAcceptEncoding() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: Accept-Encoding")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof HttpURLConnectionImpl);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof HttpURLConnectionImpl);
  assertEquals("B", readAscii(connection2));
}
 
Example 17
Project: PriorityOkHttp   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVary() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: Accept-Language")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof HttpURLConnectionImpl);
  connection.setRequestProperty("Accept-Language", "en-US");
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof HttpURLConnectionImpl);
  assertEquals("B", readAscii(connection2));
}
 
Example 18
Project: PriorityOkHttp   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVaryAsterisk() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: *")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof HttpURLConnectionImpl);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof HttpURLConnectionImpl);
  assertEquals("B", readAscii(connection2));
}
 
Example 19
Project: Okhttp   File: CacheAdapterTest.java   Source Code and License 6 votes vote down vote up
@Test public void get_httpGet() throws Exception {
  final URL serverUrl = configureServer(new MockResponse());
  assertEquals("http", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheResponse get(
        URI uri, String method, Map<String, List<String>> headers) throws IOException {
      try {
        assertEquals(toUri(serverUrl), uri);
        assertEquals("GET", method);
        assertTrue("Arbitrary standard header not present", headers.containsKey("User-Agent"));
        assertEquals(Collections.singletonList("value1"), headers.get("key1"));
        return null;
      } catch (Throwable t) {
        throw new IOException("unexpected cache failure", t);
      }
    }
  };
  setInternalCache(new CacheAdapter(responseCache));

  connection = new OkUrlFactory(client).open(serverUrl);
  connection.setRequestProperty("key1", "value1");

  executeGet(connection);
}
 
Example 20
Project: Okhttp   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheHitWithoutVary() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("FAIL"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection2));
}
 
Example 21
Project: Okhttp   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVaryAcceptEncoding() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: Accept-Encoding")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("B", readAscii(connection2));
}
 
Example 22
Project: Okhttp   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVary() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: Accept-Language")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  connection.setRequestProperty("Accept-Language", "en-US");
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("B", readAscii(connection2));
}
 
Example 23
Project: Okhttp   File: ResponseCacheTest.java   Source Code and License 6 votes vote down vote up
@Test public void otherStacks_cacheMissWithVaryAsterisk() throws Exception {
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .addHeader("Vary: *")
      .setBody("A"));
  server.enqueue(new MockResponse()
      .setBody("B"));

  // Set the cache as the shared cache.
  ResponseCache.setDefault(cache);

  // Use the platform's HTTP stack.
  URLConnection connection = server.url("/").url().openConnection();
  assertFalse(connection instanceof OkHttpURLConnection);
  assertEquals("A", readAscii(connection));

  URLConnection connection2 = server.url("/").url().openConnection();
  assertFalse(connection2 instanceof OkHttpURLConnection);
  assertEquals("B", readAscii(connection2));
}
 
Example 24
Project: smart-mirror-app   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 25
Project: cordova-plugin-background-mode   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 26
Project: multirotorstuff-vtx-calc   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 27
Project: L.TileLayer.Cordova   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 28
Project: cordova-android-tv   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 29
Project: Cordova-Locale-Plugin   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 30
Project: gwt-material-phonegap   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 31
Project: pubnub-rpi-smart-parking   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 32
Project: IoTgo_Android_App   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 33
Project: CanDoVS2015   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 34
Project: krakn   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 35
Project: krakn   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 36
Project: krakn   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 37
Project: wototoplayer   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 38
Project: krakn   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 39
Project: krakn   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 40
Project: posjs2   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 41
Project: hustElectricity   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 42
Project: Wetube   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 43
Project: DemoArduinoAndroidCordovaBT   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 44
Project: cordova-muse   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 45
Project: MinWageCalc   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 46
Project: hackmxdf-2015   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 47
Project: bluemix-parking-meter   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 48
Project: NgFileExplorer   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 49
Project: CrossWalkAndroidStudio   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 50
Project: CrossWalkAndroidStudio   File: OkHttpClient.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a shallow copy of this OkHttpClient that uses the system-wide default for
 * each field that hasn't been explicitly configured.
 */
private OkHttpClient copyWithDefaults() {
  OkHttpClient result = new OkHttpClient(this);
  result.proxy = proxy;
  result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
  result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
  result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
  result.sslSocketFactory = sslSocketFactory != null
      ? sslSocketFactory
      : HttpsURLConnection.getDefaultSSLSocketFactory();
  result.hostnameVerifier = hostnameVerifier != null
      ? hostnameVerifier
      : OkHostnameVerifier.INSTANCE;
  result.authenticator = authenticator != null
      ? authenticator
      : HttpAuthenticator.SYSTEM_DEFAULT;
  result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
  result.followProtocolRedirects = followProtocolRedirects;
  result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
  result.connectTimeout = connectTimeout;
  result.readTimeout = readTimeout;
  return result;
}
 
Example 51
Project: GitHub   File: AndroidInternal.java   Source Code and License 5 votes vote down vote up
/** Sets the response cache to be used to read and write cached responses. */
public static void setResponseCache(OkUrlFactory okUrlFactory, ResponseCache responseCache) {
  OkHttpClient.Builder builder = okUrlFactory.client().newBuilder();
  if (responseCache instanceof OkCacheContainer) {
    // Avoid adding layers of wrappers. Rather than wrap the ResponseCache in yet another layer to
    // make the ResponseCache look like an InternalCache, we can unwrap the Cache instead.
    // This means that Cache stats will be correctly updated.
    OkCacheContainer okCacheContainer = (OkCacheContainer) responseCache;
    builder.cache(okCacheContainer.getCache());
  } else {
    builder.setInternalCache(responseCache != null ? new CacheAdapter(responseCache) : null);
  }
  okUrlFactory.setClient(builder.build());
}
 
Example 52
Project: GitHub   File: CacheAdapterTest.java   Source Code and License 5 votes vote down vote up
@Test public void get_httpsGet() throws Exception {
  final URL serverUrl = configureHttpsServer(new MockResponse());
  assertEquals("https", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheResponse get(URI uri, String method, Map<String, List<String>> headers)
        throws IOException {
      try {
        assertEquals("https", uri.getScheme());
        assertEquals(toUri(serverUrl), uri);
        assertEquals("GET", method);
        assertTrue("Arbitrary standard header not present", headers.containsKey("User-Agent"));
        assertEquals(Collections.singletonList("value1"), headers.get("key1"));
        return null;
      } catch (Throwable t) {
        throw new IOException("unexpected cache failure", t);
      }
    }
  };
  setInternalCache(new CacheAdapter(responseCache));
  client = client.newBuilder()
      .sslSocketFactory(sslClient.socketFactory, sslClient.trustManager)
      .hostnameVerifier(hostnameVerifier)
      .build();

  connection = new OkUrlFactory(client).open(serverUrl);
  connection.setRequestProperty("key1", "value1");

  executeGet(connection);
}
 
Example 53
Project: GitHub   File: CacheAdapterTest.java   Source Code and License 5 votes vote down vote up
@Test public void put_httpsGet() throws Exception {
  final URL serverUrl = configureHttpsServer(new MockResponse());
  assertEquals("https", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheRequest put(URI uri, URLConnection connection) throws IOException {
      try {
        assertTrue(connection instanceof HttpsURLConnection);
        assertEquals(toUri(serverUrl), uri);
        assertEquals(serverUrl, connection.getURL());

        HttpsURLConnection cacheHttpsUrlConnection = (HttpsURLConnection) connection;
        HttpsURLConnection realHttpsUrlConnection =
            (HttpsURLConnection) CacheAdapterTest.this.connection;
        assertEquals(realHttpsUrlConnection.getCipherSuite(),
            cacheHttpsUrlConnection.getCipherSuite());
        assertEquals(realHttpsUrlConnection.getPeerPrincipal(),
            cacheHttpsUrlConnection.getPeerPrincipal());
        assertArrayEquals(realHttpsUrlConnection.getLocalCertificates(),
            cacheHttpsUrlConnection.getLocalCertificates());
        assertArrayEquals(realHttpsUrlConnection.getServerCertificates(),
            cacheHttpsUrlConnection.getServerCertificates());
        assertEquals(realHttpsUrlConnection.getLocalPrincipal(),
            cacheHttpsUrlConnection.getLocalPrincipal());
        return null;
      } catch (Throwable t) {
        throw new IOException("unexpected cache failure", t);
      }
    }
  };
  setInternalCache(new CacheAdapter(responseCache));
  client = client.newBuilder()
      .sslSocketFactory(sslClient.socketFactory, sslClient.trustManager)
      .hostnameVerifier(hostnameVerifier)
      .build();

  connection = new OkUrlFactory(client).open(serverUrl);
  executeGet(connection);
}
 
Example 54
Project: GitHub   File: HttpResponseCache.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the currently-installed {@code HttpResponseCache}, or null if there is no cache
 * installed or it is not a {@code HttpResponseCache}.
 */
public static HttpResponseCache getInstalled() {
  ResponseCache installed = ResponseCache.getDefault();
  if (installed instanceof HttpResponseCache) {
    return (HttpResponseCache) installed;
  }
  return null;
}
 
Example 55
Project: GitHub   File: HttpResponseCache.java   Source Code and License 5 votes vote down vote up
/**
 * Uninstalls the cache and releases any active resources. Stored contents will remain on the
 * filesystem.
 */
@Override public void close() throws IOException {
  if (ResponseCache.getDefault() == this) {
    ResponseCache.setDefault(null);
  }
  shimResponseCache.close();
}
 
Example 56
Project: GitHub   File: HttpResponseCache.java   Source Code and License 5 votes vote down vote up
/**
 * Uninstalls the cache and deletes all of its stored contents.
 */
public void delete() throws IOException {
  if (ResponseCache.getDefault() == this) {
    ResponseCache.setDefault(null);
  }
  shimResponseCache.delete();
}
 
Example 57
Project: GitHub   File: AndroidInternal.java   Source Code and License 5 votes vote down vote up
/** Sets the response cache to be used to read and write cached responses. */
public static void setResponseCache(OkUrlFactory okUrlFactory, ResponseCache responseCache) {
  OkHttpClient.Builder builder = okUrlFactory.client().newBuilder();
  if (responseCache instanceof OkCacheContainer) {
    // Avoid adding layers of wrappers. Rather than wrap the ResponseCache in yet another layer to
    // make the ResponseCache look like an InternalCache, we can unwrap the Cache instead.
    // This means that Cache stats will be correctly updated.
    OkCacheContainer okCacheContainer = (OkCacheContainer) responseCache;
    builder.cache(okCacheContainer.getCache());
  } else {
    builder.setInternalCache(responseCache != null ? new CacheAdapter(responseCache) : null);
  }
  okUrlFactory.setClient(builder.build());
}
 
Example 58
Project: GitHub   File: CacheAdapterTest.java   Source Code and License 5 votes vote down vote up
@Test public void get_httpsGet() throws Exception {
  final URL serverUrl = configureHttpsServer(new MockResponse());
  assertEquals("https", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheResponse get(URI uri, String method, Map<String, List<String>> headers)
        throws IOException {
      try {
        assertEquals("https", uri.getScheme());
        assertEquals(toUri(serverUrl), uri);
        assertEquals("GET", method);
        assertTrue("Arbitrary standard header not present", headers.containsKey("User-Agent"));
        assertEquals(Collections.singletonList("value1"), headers.get("key1"));
        return null;
      } catch (Throwable t) {
        throw new IOException("unexpected cache failure", t);
      }
    }
  };
  setInternalCache(new CacheAdapter(responseCache));
  client = client.newBuilder()
      .sslSocketFactory(sslClient.socketFactory, sslClient.trustManager)
      .hostnameVerifier(hostnameVerifier)
      .build();

  connection = new OkUrlFactory(client).open(serverUrl);
  connection.setRequestProperty("key1", "value1");

  executeGet(connection);
}
 
Example 59
Project: GitHub   File: CacheAdapterTest.java   Source Code and License 5 votes vote down vote up
@Test public void put_httpsGet() throws Exception {
  final URL serverUrl = configureHttpsServer(new MockResponse());
  assertEquals("https", serverUrl.getProtocol());

  ResponseCache responseCache = new AbstractResponseCache() {
    @Override public CacheRequest put(URI uri, URLConnection connection) throws IOException {
      try {
        assertTrue(connection instanceof HttpsURLConnection);
        assertEquals(toUri(serverUrl), uri);
        assertEquals(serverUrl, connection.getURL());

        HttpsURLConnection cacheHttpsUrlConnection = (HttpsURLConnection) connection;
        HttpsURLConnection realHttpsUrlConnection =
            (HttpsURLConnection) CacheAdapterTest.this.connection;
        assertEquals(realHttpsUrlConnection.getCipherSuite(),
            cacheHttpsUrlConnection.getCipherSuite());
        assertEquals(realHttpsUrlConnection.getPeerPrincipal(),
            cacheHttpsUrlConnection.getPeerPrincipal());
        assertArrayEquals(realHttpsUrlConnection.getLocalCertificates(),
            cacheHttpsUrlConnection.getLocalCertificates());
        assertArrayEquals(realHttpsUrlConnection.getServerCertificates(),
            cacheHttpsUrlConnection.getServerCertificates());
        assertEquals(realHttpsUrlConnection.getLocalPrincipal(),
            cacheHttpsUrlConnection.getLocalPrincipal());
        return null;
      } catch (Throwable t) {
        throw new IOException("unexpected cache failure", t);
      }
    }
  };
  setInternalCache(new CacheAdapter(responseCache));
  client = client.newBuilder()
      .sslSocketFactory(sslClient.socketFactory, sslClient.trustManager)
      .hostnameVerifier(hostnameVerifier)
      .build();

  connection = new OkUrlFactory(client).open(serverUrl);
  executeGet(connection);
}
 
Example 60
Project: GitHub   File: HttpResponseCache.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the currently-installed {@code HttpResponseCache}, or null if there is no cache
 * installed or it is not a {@code HttpResponseCache}.
 */
public static HttpResponseCache getInstalled() {
  ResponseCache installed = ResponseCache.getDefault();
  if (installed instanceof HttpResponseCache) {
    return (HttpResponseCache) installed;
  }
  return null;
}