Example usage for org.apache.http.impl.client.cache SizeLimitedResponseReader getResource

List of usage examples for org.apache.http.impl.client.cache SizeLimitedResponseReader getResource

Introduction

In this page you can find the example usage for org.apache.http.impl.client.cache SizeLimitedResponseReader getResource.

Prototype

Resource getResource() 

Source Link

Usage

From source file:org.apache.http.impl.client.cache.BasicHttpCache.java

public HttpResponse cacheAndReturnResponse(HttpHost host, HttpRequest request, HttpResponse originResponse,
        Date requestSent, Date responseReceived) throws IOException {

    SizeLimitedResponseReader responseReader = getResponseReader(request, originResponse);
    responseReader.readResponse();//from   w w w.  ja  va  2 s .  c o m

    if (responseReader.isLimitReached()) {
        return responseReader.getReconstructedResponse();
    }

    Resource resource = responseReader.getResource();
    if (isIncompleteResponse(originResponse, resource)) {
        return generateIncompleteResponseError(originResponse, resource);
    }

    HttpCacheEntry entry = new HttpCacheEntry(requestSent, responseReceived, originResponse.getStatusLine(),
            originResponse.getAllHeaders(), resource);
    storeInCache(host, request, entry);
    return responseGenerator.generateResponse(entry);
}