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

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

Introduction

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

Prototype

HttpResponse getReconstructedResponse() throws IOException 

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();/*  w ww.  j  a va2s .co 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);
}