use of org.apache.hc.core5.http.message.BasicHttpResponse in project httpcomponents-core by apache.
the class TestDefaultConnectionReuseStrategy method testRequestExplicitClose.
@Test
public void testRequestExplicitClose() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, "/");
request.addHeader("Connection", "close");
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Transfer-Encoding", "chunked");
response.addHeader("Connection", "keep-alive");
Assertions.assertFalse(reuseStrategy.keepAlive(request, response, context));
}
use of org.apache.hc.core5.http.message.BasicHttpResponse in project httpcomponents-core by apache.
the class TestDefaultConnectionReuseStrategy method testHttp204ContentLengthEqualToZero.
@Test
public void testHttp204ContentLengthEqualToZero() throws Exception {
final HttpResponse response = new BasicHttpResponse(204, "OK");
response.addHeader("Content-Length", "0");
response.addHeader("Connection", "keep-alive");
Assertions.assertTrue(reuseStrategy.keepAlive(null, response, context));
}
use of org.apache.hc.core5.http.message.BasicHttpResponse in project httpcomponents-core by apache.
the class TestDefaultConnectionReuseStrategy method testHTTP11Default.
@Test
public void testHTTP11Default() throws Exception {
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Content-Length", "10");
Assertions.assertTrue(reuseStrategy.keepAlive(null, response, context));
}
use of org.apache.hc.core5.http.message.BasicHttpResponse in project httpcomponents-core by apache.
the class TestDefaultConnectionReuseStrategy method testRequestNoExplicitClose.
@Test
public void testRequestNoExplicitClose() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, "/");
request.addHeader("Connection", "blah, blah, blah");
final HttpResponse response = new BasicHttpResponse(200, "OK");
response.addHeader("Transfer-Encoding", "chunked");
response.addHeader("Connection", "keep-alive");
Assertions.assertTrue(reuseStrategy.keepAlive(request, response, context));
}
use of org.apache.hc.core5.http.message.BasicHttpResponse in project httpcomponents-core by apache.
the class TestDefaultConnectionReuseStrategy method testNoContentLengthResponseHttp1_1.
@Test
public void testNoContentLengthResponseHttp1_1() throws Exception {
final HttpResponse response = new BasicHttpResponse(200, "OK");
Assertions.assertFalse(reuseStrategy.keepAlive(null, response, context));
}
Aggregations