Package org.apache.http.message

Examples of org.apache.http.message.BasicHttpResponse.addHeader()


    public void testConnectionTokens6() throws Exception {
        // Use HTTP 1.1
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Transfer-Encoding", "chunked");
        response.addHeader("Connection", "");
        response.addHeader("Proxy-Connection", "close");
        // Connection takes precedence over Proxy-Connection,
        // even if it is empty. Default for HTTP/1.1 is to keep alive.
        assertTrue(reuseStrategy.keepAlive(response, context));
    }
View Full Code Here


    }

    public void testConnectionTokensInvalid() throws Exception {
        // Use HTTP 1.1
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Transfer-Encoding", "chunked");
        response.addHeader("Connection", "keep-alive=true");
        assertFalse(reuseStrategy.keepAlive(response, context));
    }

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

    public void testConnectionTokensInvalid() throws Exception {
        // Use HTTP 1.1
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Transfer-Encoding", "chunked");
        response.addHeader("Connection", "keep-alive=true");
        assertFalse(reuseStrategy.keepAlive(response, context));
    }

    public void testMultipleContentLength() throws Exception {
        // Use HTTP 1.1
View Full Code Here

    }

    public void testMultipleContentLength() throws Exception {
        // Use HTTP 1.1
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Content-Length", "10");
        response.addHeader("Content-Length", "11");
        assertFalse(reuseStrategy.keepAlive(response, context));
    }

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

    public void testMultipleContentLength() throws Exception {
        // Use HTTP 1.1
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Content-Length", "10");
        response.addHeader("Content-Length", "11");
        assertFalse(reuseStrategy.keepAlive(response, context));
    }

    public void testInvalidContentLength() throws Exception {
        // Use HTTP 1.1
View Full Code Here

    }

    public void testInvalidContentLength() throws Exception {
        // Use HTTP 1.1
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Content-Length", "crap");
        assertFalse(reuseStrategy.keepAlive(response, context));
    }

    public void testInvalidNegativeContentLength() throws Exception {
        // Use HTTP 1.1
View Full Code Here

    }

    public void testInvalidNegativeContentLength() throws Exception {
        // Use HTTP 1.1
        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Content-Length", "-10");
        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

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.