use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseConnControlEntityContentLength.
@Test
public void testResponseConnControlEntityContentLength() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
response.setEntity(new StringEntity("whatever"));
final ResponseConnControl interceptor = new ResponseConnControl();
interceptor.process(response, response.getEntity(), context);
final Header header = response.getFirstHeader(HttpHeaders.CONNECTION);
Assertions.assertNull(header);
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseContentEntityNoContentTypeAndEncoding.
@Test
public void testResponseContentEntityNoContentTypeAndEncoding() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
response.setEntity(new BasicHttpEntity(EmptyInputStream.INSTANCE, null));
final ResponseContent interceptor = new ResponseContent();
interceptor.process(response, response.getEntity(), context);
final Header h1 = response.getFirstHeader(HttpHeaders.CONTENT_TYPE);
Assertions.assertNull(h1);
final Header h2 = response.getFirstHeader(HttpHeaders.CONTENT_ENCODING);
Assertions.assertNull(h2);
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseDateNotGenerated.
@Test
public void testResponseDateNotGenerated() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
response.setCode(199);
final ResponseDate interceptor = new ResponseDate();
interceptor.process(response, response.getEntity(), context);
final Header h1 = response.getFirstHeader(HttpHeaders.DATE);
Assertions.assertNull(h1);
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseContentEntityUnknownContentLength.
@Test
public void testResponseContentEntityUnknownContentLength() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
response.setEntity(new BasicHttpEntity(EmptyInputStream.INSTANCE, null));
final ResponseContent interceptor = new ResponseContent();
interceptor.process(response, response.getEntity(), context);
final Header h1 = response.getFirstHeader(HttpHeaders.TRANSFER_ENCODING);
Assertions.assertNotNull(h1);
Assertions.assertEquals("chunked", h1.getValue());
final Header h2 = response.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
Assertions.assertNull(h2);
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseConnControlExplicitClose.
@Test
public void testResponseConnControlExplicitClose() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final BasicClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, "/");
request.addHeader(new BasicHeader(HttpHeaders.CONNECTION, "keep-alive"));
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
final ResponseConnControl interceptor = new ResponseConnControl();
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
response.setHeader(HttpHeaders.CONNECTION, "close");
interceptor.process(response, response.getEntity(), context);
final Header header = response.getFirstHeader(HttpHeaders.CONNECTION);
Assertions.assertNotNull(header);
Assertions.assertEquals("close", header.getValue());
}
Aggregations