use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseServerNotGenerated.
@Test
public void testResponseServerNotGenerated() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
response.addHeader(new BasicHeader(HttpHeaders.SERVER, "whatever"));
final ResponseServer interceptor = new ResponseServer("some server");
interceptor.process(response, response.getEntity(), context);
final Header h1 = response.getFirstHeader(HttpHeaders.SERVER);
Assertions.assertNotNull(h1);
Assertions.assertEquals("whatever", h1.getValue());
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseContentStatusNotModified.
@Test
public void testResponseContentStatusNotModified() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
response.setCode(HttpStatus.SC_NOT_MODIFIED);
final ResponseContent interceptor = new ResponseContent();
interceptor.process(response, response.getEntity(), context);
final Header header = response.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
Assertions.assertNull(header);
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseDateGenerated.
@Test
public void testResponseDateGenerated() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
final ResponseDate interceptor = new ResponseDate();
interceptor.process(response, response.getEntity(), context);
final Header h1 = response.getFirstHeader(HttpHeaders.DATE);
Assertions.assertNotNull(h1);
interceptor.process(response, response.getEntity(), context);
final Header h2 = response.getFirstHeader(HttpHeaders.DATE);
Assertions.assertNotNull(h2);
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseConnControlHostInvalidInput.
@Test
public void testResponseConnControlHostInvalidInput() throws Exception {
final ResponseConnControl interceptor = new ResponseConnControl();
Assertions.assertThrows(NullPointerException.class, () -> interceptor.process(null, null, null));
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
Assertions.assertThrows(NullPointerException.class, () -> interceptor.process(response, null, null));
}
use of org.apache.hc.core5.http.message.BasicClassicHttpResponse in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseConnControlEntityUnknownContentLengthHTTP10.
@Test
public void testResponseConnControlEntityUnknownContentLengthHTTP10() throws Exception {
final HttpContext context = new BasicHttpContext(null);
context.setProtocolVersion(HttpVersion.HTTP_1_0);
final BasicClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, "/");
request.addHeader(new BasicHeader(HttpHeaders.CONNECTION, "keep-alive"));
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
final BasicClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
response.setEntity(new BasicHttpEntity(EmptyInputStream.INSTANCE, null));
final ResponseConnControl interceptor = new ResponseConnControl();
interceptor.process(response, response.getEntity(), context);
final Header header = response.getFirstHeader(HttpHeaders.CONNECTION);
Assertions.assertNotNull(header);
Assertions.assertEquals("close", header.getValue());
}
Aggregations