Code example for BasicHttpResponse

Methods: addHeader

0
    } 
 
    @Test 
    public void testExplicitClose() throws Exception { 
        // Use HTTP 1.1 
        final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader("Transfer-Encoding", "chunked");
        response.addHeader("Connection", "close");
        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
    } 
 
    @Test 
    public void testExplicitKeepAlive() throws Exception { 
        // Use HTTP 1.0 
        final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
        response.addHeader("Content-Length", "10");
        response.addHeader("Connection", "keep-alive");
 
        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
    }