Package org.apache.http

Examples of org.apache.http.HttpResponse.addHeader()


    }

    public void testIgnoreInvalidKeepAlive() throws Exception {
        HttpResponse response =
            createResponse(HttpVersion.HTTP_1_0, 200, "OK", false, -1);
        response.addHeader("Connection", "keep-alive");

        assertFalse(reuseStrategy.keepAlive(response, context));
    }
   
    public void testExplicitClose() throws Exception {
View Full Code Here


   
    public void testExplicitClose() throws Exception {
        // Use HTTP 1.1
        HttpResponse response =
            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);
        response.addHeader("Connection", "close");

        assertFalse(reuseStrategy.keepAlive(response, context));
    }
   
    public void testExplicitKeepAlive() throws Exception {
View Full Code Here

   
    public void testExplicitKeepAlive() throws Exception {
        // Use HTTP 1.0
        HttpResponse response =
            createResponse(HttpVersion.HTTP_1_0, 200, "OK", false, 10);
        response.addHeader("Connection", "keep-alive");

        assertTrue(reuseStrategy.keepAlive(response, context));
    }

    public void testHTTP10Default() throws Exception {
View Full Code Here

   
    public void testBrokenConnectionDirective1() throws Exception {
        // Use HTTP 1.0
        HttpResponse response =
            createResponse(HttpVersion.HTTP_1_0, 200, "OK");
        response.addHeader("Connection", "keep--alive");

        assertFalse(reuseStrategy.keepAlive(response, context));
    }

    public void testBrokenConnectionDirective2() throws Exception {
View Full Code Here

    public void testBrokenConnectionDirective2() throws Exception {
        // Use HTTP 1.0
        HttpResponse response =
            createResponse(HttpVersion.HTTP_1_0, 200, "OK");
        response.addHeader("Connection", null);

        assertFalse(reuseStrategy.keepAlive(response, context));
    }

View Full Code Here

    public void testEmptyKeepAliveHeader() 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, max=20");
        ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
        long d = keepAliveStrat.getKeepAliveDuration(response, context);
        assertEquals(-1, d);
    }
View Full Code Here

    public void testInvalidKeepAliveHeader() 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=whatever, max=20");
        ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
        long d = keepAliveStrat.getKeepAliveDuration(response, context);
        assertEquals(-1, d);
    }
View Full Code Here

    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

        assertFalse(reuseStrategy.keepAlive(response, context));
    }

    public void testChunkedContent() throws Exception {
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Transfer-Encoding", "chunked");
        assertTrue(reuseStrategy.keepAlive(response, context));
    }

    public void testIgnoreInvalidKeepAlive() throws Exception {
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
View Full Code Here

        assertTrue(reuseStrategy.keepAlive(response, context));
    }

    public void testIgnoreInvalidKeepAlive() throws Exception {
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
        response.addHeader("Connection", "keep-alive");

        assertFalse(reuseStrategy.keepAlive(response, context));
    }

    public void testExplicitClose() throws Exception {
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.