/** * Update the entry with the new information from the response. Should only be used for 304 * responses. * * @param requestId * @param entry The cache Entry to be updated * @param requestDate When the request was performed * @param responseDate When the response was gotten * @param response The HttpResponse from the backend server call * @return HttpCacheEntry an updated version of the cache entry * @throws java.io.IOException if something bad happens while trying to read the body from the * original entry */ public HttpCacheEntry updateCacheEntry( String requestId, HttpCacheEntry entry, Date requestDate, Date responseDate, HttpResponse response) throws IOException { if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NOT_MODIFIED) throw new IllegalArgumentException("Response must have 304 status code"); Header[] mergedHeaders = mergeHeaders(entry, response); Resource resource = resourceFactory.copy(requestId, entry.getResource()); return new HttpCacheEntry( requestDate, responseDate, entry.getStatusLine(), mergedHeaders, resource); }