Examples of BasicStatusLine


Examples of org.apache.http.message.BasicStatusLine

    }

    public void testKeepAliveHeader() throws Exception {
        HttpContext context = new BasicHttpContext(null);
        HttpResponse response = new BasicHttpResponse(
                new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK"));
        response.addHeader("Keep-Alive", "timeout=300, max=20");
        ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
        long d = keepAliveStrat.getKeepAliveDuration(response, context);
        assertEquals(300000, d);
    }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

        return new TestSuite(TestHttpOptions.class);
    }

    public void testMultipleAllows() {
        ProtocolVersion proto = new ProtocolVersion("HTTP", 1, 1);
        BasicStatusLine line = new BasicStatusLine(proto, 200, "test reason");
        BasicHttpResponse resp = new BasicHttpResponse(line);
        resp.addHeader("Allow", "POST");
        resp.addHeader("Allow", "GET");

        HttpOptions opt = new HttpOptions();
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

            return handleBackendResponse(target, request, requestDate, getCurrentDate(),
                                         backendResponse);
        } catch (ClientProtocolException cpex) {
            throw cpex;
        } catch (IOException ex) {
            StatusLine status = new BasicStatusLine(HTTP_1_1, HttpStatus.SC_SERVICE_UNAVAILABLE, ex
                    .getMessage());
            return new BasicHttpResponse(status);
        }

    }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

    }

    public HttpResponse getErrorForRequest(RequestProtocolError errorCheck) {
        switch (errorCheck) {
        case BODY_BUT_NO_LENGTH_ERROR:
            return new BasicHttpResponse(new BasicStatusLine(CachingHttpClient.HTTP_1_1,
                    HttpStatus.SC_LENGTH_REQUIRED, ""));

        case WEAK_ETAG_AND_RANGE_ERROR:
            return new BasicHttpResponse(new BasicStatusLine(CachingHttpClient.HTTP_1_1,
                    HttpStatus.SC_BAD_REQUEST, "Weak eTag not compatible with byte range"));

        case WEAK_ETAG_ON_PUTDELETE_METHOD_ERROR:
            return new BasicHttpResponse(new BasicStatusLine(CachingHttpClient.HTTP_1_1,
                    HttpStatus.SC_BAD_REQUEST,
                    "Weak eTag not compatible with PUT or DELETE requests"));

        default:
            throw new IllegalStateException(
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

    @Before
    public void setUp() throws Exception {
        policy = new ResponseCachingPolicy(0);
        response = new BasicHttpResponse(
                new BasicStatusLine(PROTOCOL_VERSION, HttpStatus.SC_OK, ""));
        response.setHeader("Date", DateUtils.formatDate(new Date()));
        response.setHeader("Content-Length", "0");
    }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

        response.addHeader("Cache-Control", "max=10");

        Assert.assertTrue(policy.isResponseCacheable("GET", response));

        response = new BasicHttpResponse(
                new BasicStatusLine(PROTOCOL_VERSION, HttpStatus.SC_OK, ""));
        response.setHeader("Date", DateUtils.formatDate(new Date()));
        response.addHeader("Cache-Control", "no-transform");
        response.setHeader("Content-Length", "0");

        Assert.assertTrue(policy.isResponseCacheable("GET", response));
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

        Assert.assertTrue(policy.isResponseCacheable("GET", response));
    }

    @Test
    public void testIsGetWithout200Cacheable() {
        HttpResponse response = new BasicHttpResponse(new BasicStatusLine(PROTOCOL_VERSION,
                HttpStatus.SC_NOT_FOUND, ""));

        Assert.assertFalse(policy.isResponseCacheable("GET", response));

        response = new BasicHttpResponse(new BasicStatusLine(PROTOCOL_VERSION,
                HttpStatus.SC_GATEWAY_TIMEOUT, ""));

        Assert.assertFalse(policy.isResponseCacheable("GET", response));
    }
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

                new BasicHeader("Date", DateUtils.formatDate(responseDate)),
                new BasicHeader("ETag", "\"etag\"")};

        CacheEntry cacheEntry = getEntry(headers);

        HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion(
                "http", 1, 1), HttpStatus.SC_NOT_MODIFIED, ""));
        response.setHeaders(new Header[]{});

        CacheEntry updatedEntry = impl.updateCacheEntry(cacheEntry, new Date(), new Date(), response);
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

                new BasicHeader("Cache-Control", "private"), new BasicHeader("ETag", "\"etag\""),
                new BasicHeader("Last-Modified", DateUtils.formatDate(requestDate)),
                new BasicHeader("Cache-Control", "max-age=0"),};
        CacheEntry cacheEntry = getEntry(headers);

        HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion(
                "http", 1, 1), HttpStatus.SC_NOT_MODIFIED, ""));
        response.setHeaders(new Header[]{
                new BasicHeader("Last-Modified", DateUtils.formatDate(responseDate)),
                new BasicHeader("Cache-Control", "public"),});
View Full Code Here

Examples of org.apache.http.message.BasicStatusLine

        Header[] headers = {
                new BasicHeader("Date", DateUtils.formatDate(requestDate)),
                new BasicHeader("ETag", "\"etag\"")};

        CacheEntry cacheEntry = getEntry(headers);
        HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion(
                "http", 1, 1), HttpStatus.SC_NOT_MODIFIED, ""));
        response.setHeaders(new Header[]{
                new BasicHeader("Last-Modified", DateUtils.formatDate(responseDate)),
                new BasicHeader("Cache-Control", "public"),});
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.