private void update(CacheResponse conditionalCacheHit, HttpURLConnection httpConnection) throws IOException { HttpEngine httpEngine = getHttpEngine(httpConnection); URI uri = httpEngine.getUri(); ResponseHeaders response = httpEngine.getResponseHeaders(); RawHeaders varyHeaders = httpEngine.getRequestHeaders().getHeaders().getAll(response.getVaryFields()); Entry entry = new Entry(uri, varyHeaders, httpConnection); DiskLruCache.Snapshot snapshot = (conditionalCacheHit instanceof EntryCacheResponse) ? ((EntryCacheResponse) conditionalCacheHit).snapshot : ((EntrySecureCacheResponse) conditionalCacheHit).snapshot; DiskLruCache.Editor editor = null; try { editor = snapshot.edit(); // returns null if snapshot is not current if (editor != null) { entry.writeTo(editor); editor.commit(); } } catch (IOException e) { abortQuietly(editor); } }
public boolean matches(URI uri, String requestMethod, Map<String, List<String>> requestHeaders) { return this.uri.equals(uri.toString()) && this.requestMethod.equals(requestMethod) && new ResponseHeaders(uri, responseHeaders).varyMatches(varyHeaders.toMultimap(false), requestHeaders); }