Java Code Examples for com.squareup.okhttp.OkResponseCache#maybeRemove()

The following examples show how to use com.squareup.okhttp.OkResponseCache#maybeRemove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpEngine.java    From L.TileLayer.Cordova with MIT License 6 votes vote down vote up
private void maybeCache() throws IOException {
  // Are we caching at all?
  if (!policy.getUseCaches()) return;
  OkResponseCache responseCache = client.getOkResponseCache();
  if (responseCache == null) return;

  HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

  // Should we cache this response for this request?
  if (!responseHeaders.isCacheable(requestHeaders)) {
    responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
    return;
  }

  // Offer this request to the cache.
  cacheRequest = responseCache.put(uri, connectionToCache);
}
 
Example 2
Source File: HttpEngine.java    From IoTgo_Android_App with MIT License 6 votes vote down vote up
private void maybeCache() throws IOException {
  // Are we caching at all?
  if (!policy.getUseCaches()) return;
  OkResponseCache responseCache = client.getOkResponseCache();
  if (responseCache == null) return;

  HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

  // Should we cache this response for this request?
  if (!responseHeaders.isCacheable(requestHeaders)) {
    responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
    return;
  }

  // Offer this request to the cache.
  cacheRequest = responseCache.put(uri, connectionToCache);
}
 
Example 3
Source File: HttpEngine.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
private void maybeCache() throws IOException {
    // Are we caching at all?
    if (!policy.getUseCaches())
        return;
    OkResponseCache responseCache = client.getOkResponseCache();
    if (responseCache == null)
        return;

    HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

    // Should we cache this response for this request?
    if (!responseHeaders.isCacheable(requestHeaders)) {
        responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
        return;
    }

    // Offer this request to the cache.
    cacheRequest = responseCache.put(uri, connectionToCache);
}
 
Example 4
Source File: HttpEngine.java    From bluemix-parking-meter with MIT License 6 votes vote down vote up
private void maybeCache() throws IOException {
  // Are we caching at all?
  if (!policy.getUseCaches()) return;
  OkResponseCache responseCache = client.getOkResponseCache();
  if (responseCache == null) return;

  HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

  // Should we cache this response for this request?
  if (!responseHeaders.isCacheable(requestHeaders)) {
    responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
    return;
  }

  // Offer this request to the cache.
  cacheRequest = responseCache.put(uri, connectionToCache);
}
 
Example 5
Source File: HttpEngine.java    From reader with MIT License 6 votes vote down vote up
private void maybeCache() throws IOException {
  // Are we caching at all?
  if (!policy.getUseCaches()) return;
  OkResponseCache responseCache = client.getOkResponseCache();
  if (responseCache == null) return;

  HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

  // Should we cache this response for this request?
  if (!responseHeaders.isCacheable(requestHeaders)) {
    responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
    return;
  }

  // Offer this request to the cache.
  cacheRequest = responseCache.put(uri, connectionToCache);
}
 
Example 6
Source File: HttpEngine.java    From reader with MIT License 6 votes vote down vote up
private void maybeCache() throws IOException {
  // Are we caching at all?
  if (!policy.getUseCaches()) return;
  OkResponseCache responseCache = client.getOkResponseCache();
  if (responseCache == null) return;

  HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

  // Should we cache this response for this request?
  if (!responseHeaders.isCacheable(requestHeaders)) {
    responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
    return;
  }

  // Offer this request to the cache.
  cacheRequest = responseCache.put(uri, connectionToCache);
}
 
Example 7
Source File: HttpEngine.java    From cordova-amazon-fireos with Apache License 2.0 6 votes vote down vote up
private void maybeCache() throws IOException {
  // Are we caching at all?
  if (!policy.getUseCaches()) return;
  OkResponseCache responseCache = client.getOkResponseCache();
  if (responseCache == null) return;

  HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

  // Should we cache this response for this request?
  if (!responseHeaders.isCacheable(requestHeaders)) {
    responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
    return;
  }

  // Offer this request to the cache.
  cacheRequest = responseCache.put(uri, connectionToCache);
}
 
Example 8
Source File: HttpEngine.java    From phonegapbootcampsite with MIT License 6 votes vote down vote up
private void maybeCache() throws IOException {
  // Are we caching at all?
  if (!policy.getUseCaches()) return;
  OkResponseCache responseCache = client.getOkResponseCache();
  if (responseCache == null) return;

  HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

  // Should we cache this response for this request?
  if (!responseHeaders.isCacheable(requestHeaders)) {
    responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
    return;
  }

  // Offer this request to the cache.
  cacheRequest = responseCache.put(uri, connectionToCache);
}
 
Example 9
Source File: HttpEngine.java    From CordovaYoutubeVideoPlayer with MIT License 6 votes vote down vote up
private void maybeCache() throws IOException {
  // Are we caching at all?
  if (!policy.getUseCaches()) return;
  OkResponseCache responseCache = client.getOkResponseCache();
  if (responseCache == null) return;

  HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

  // Should we cache this response for this request?
  if (!responseHeaders.isCacheable(requestHeaders)) {
    responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
    return;
  }

  // Offer this request to the cache.
  cacheRequest = responseCache.put(uri, connectionToCache);
}
 
Example 10
Source File: HttpEngine.java    From wildfly-samples with MIT License 6 votes vote down vote up
private void maybeCache() throws IOException {
  // Are we caching at all?
  if (!policy.getUseCaches()) return;
  OkResponseCache responseCache = client.getOkResponseCache();
  if (responseCache == null) return;

  HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

  // Should we cache this response for this request?
  if (!responseHeaders.isCacheable(requestHeaders)) {
    responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
    return;
  }

  // Offer this request to the cache.
  cacheRequest = responseCache.put(uri, connectionToCache);
}
 
Example 11
Source File: HttpEngine.java    From crosswalk-cordova-android with Apache License 2.0 6 votes vote down vote up
private void maybeCache() throws IOException {
  // Are we caching at all?
  if (!policy.getUseCaches()) return;
  OkResponseCache responseCache = client.getOkResponseCache();
  if (responseCache == null) return;

  HttpURLConnection connectionToCache = policy.getHttpConnectionToCache();

  // Should we cache this response for this request?
  if (!responseHeaders.isCacheable(requestHeaders)) {
    responseCache.maybeRemove(connectionToCache.getRequestMethod(), uri);
    return;
  }

  // Offer this request to the cache.
  cacheRequest = responseCache.put(uri, connectionToCache);
}