Package org.apache.http.client.cache

Examples of org.apache.http.client.cache.Resource


        HttpCacheEntry src = existing;
        if (src == null) {
            src = entry;
        }

        Resource resource = null;
        if (src.getResource() != null) {
            resource = resourceFactory.copy(requestId, src.getResource());
        }
        Map<String,String> variantMap = new HashMap<String,String>(src.getVariantMap());
        variantMap.put(variantKey, variantCacheKey);
View Full Code Here


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

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

            HttpCacheEntry entry = new HttpCacheEntry(
View Full Code Here

            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 = null;
        if (entry.getResource() != null) {
            resource = resourceFactory.copy(requestId, entry.getResource());
        }
        return new HttpCacheEntry(
                requestDate,
View Full Code Here

        HttpCacheEntry src = existing;
        if (src == null) {
            src = entry;
        }

        final Resource oldResource = entry.getResource();
        Resource resource = null;
        if (oldResource != null) {
            resource = resourceFactory.copy(requestId, entry.getResource());
            oldResource.dispose();
        }
        final Map<String,String> variantMap = new HashMap<String,String>(src.getVariantMap());
View Full Code Here

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

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

            final HttpCacheEntry entry = new HttpCacheEntry(
View Full Code Here

            final Date responseDate,
            final HttpResponse response) throws IOException {
        Args.check(response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_MODIFIED,
                "Response must have 304 status code");
        final Header[] mergedHeaders = mergeHeaders(entry, response);
        final Resource oldResource = entry.getResource();
        Resource resource = null;
        if (oldResource != null) {
            resource = resourceFactory.copy(requestId, entry.getResource());
            oldResource.dispose();
        }
        return new HttpCacheEntry(
View Full Code Here

        throws Exception {
        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        final byte[] bytes = HttpTestUtils.getRandomBytes(128);
        resp.setEntity(new ByteArrayEntity(bytes));
        resp.setHeader("Content-Length","128");
        final Resource resource = new HeapResource(bytes);

        assertFalse(impl.isIncompleteResponse(resp, resource));
    }
View Full Code Here

    @Test
    public void testRecognizesComplete206Response()
        throws Exception {
        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
        final byte[] bytes = HttpTestUtils.getRandomBytes(128);
        final Resource resource = new HeapResource(bytes);
        resp.setEntity(new ByteArrayEntity(bytes));
        resp.setHeader("Content-Length","128");
        resp.setHeader("Content-Range","bytes 0-127/255");

        assertFalse(impl.isIncompleteResponse(resp, resource));
View Full Code Here

    @Test
    public void testRecognizesIncomplete200Response()
        throws Exception {
        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        final byte[] bytes = HttpTestUtils.getRandomBytes(128);
        final Resource resource = new HeapResource(bytes);
        resp.setEntity(new ByteArrayEntity(bytes));
        resp.setHeader("Content-Length","256");

        assertTrue(impl.isIncompleteResponse(resp, resource));
    }
View Full Code Here

    @Test
    public void testIgnoresIncompleteNon200Or206Responses()
        throws Exception {
        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_FORBIDDEN, "Forbidden");
        final byte[] bytes = HttpTestUtils.getRandomBytes(128);
        final Resource resource = new HeapResource(bytes);
        resp.setEntity(new ByteArrayEntity(bytes));
        resp.setHeader("Content-Length","256");

        assertFalse(impl.isIncompleteResponse(resp, resource));
    }
View Full Code Here

TOP

Related Classes of org.apache.http.client.cache.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.