use of org.apache.hc.core5.http.io.entity.BasicHttpEntity in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseContentEntityContentLenghtDelimited.
@Test
public void testResponseContentEntityContentLenghtDelimited() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
response.setEntity(new BasicHttpEntity(EmptyInputStream.INSTANCE, 10, null));
final ResponseContent interceptor = new ResponseContent();
interceptor.process(response, response.getEntity(), context);
final Header h1 = response.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
Assertions.assertNotNull(h1);
Assertions.assertEquals("10", h1.getValue());
final Header h2 = response.getFirstHeader(HttpHeaders.TRANSFER_ENCODING);
Assertions.assertNull(h2);
}
use of org.apache.hc.core5.http.io.entity.BasicHttpEntity in project httpcomponents-core by apache.
the class TestStandardInterceptors method testRequestContentNullTypeAndEncoding.
@Test
public void testRequestContentNullTypeAndEncoding() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final BasicClassicHttpRequest request = new BasicClassicHttpRequest(Method.POST, "/");
request.setEntity(new BasicHttpEntity(EmptyInputStream.INSTANCE, null, null));
final HttpRequestInterceptor interceptor = RequestContent.INSTANCE;
interceptor.process(request, request.getEntity(), context);
Assertions.assertNull(request.getFirstHeader(HttpHeaders.CONTENT_TYPE));
Assertions.assertNull(request.getFirstHeader(HttpHeaders.CONTENT_ENCODING));
}
use of org.apache.hc.core5.http.io.entity.BasicHttpEntity in project httpcomponents-core by apache.
the class TestStandardInterceptors method testRequestContentEntityUnknownLengthHTTP11.
@Test
public void testRequestContentEntityUnknownLengthHTTP11() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final BasicClassicHttpRequest request = new BasicClassicHttpRequest(Method.POST, "/");
request.setEntity(new BasicHttpEntity(EmptyInputStream.INSTANCE, -1, null));
final HttpRequestInterceptor interceptor = RequestContent.INSTANCE;
interceptor.process(request, request.getEntity(), context);
final Header header = request.getFirstHeader(HttpHeaders.TRANSFER_ENCODING);
Assertions.assertNotNull(header);
Assertions.assertEquals("chunked", header.getValue());
Assertions.assertNull(request.getFirstHeader(HttpHeaders.CONTENT_LENGTH));
}
use of org.apache.hc.core5.http.io.entity.BasicHttpEntity in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseContentEntityChunked.
@Test
public void testResponseContentEntityChunked() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
response.setEntity(new BasicHttpEntity(EmptyInputStream.INSTANCE, null, true));
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.io.entity.BasicHttpEntity in project httpcomponents-core by apache.
the class TestStandardInterceptors method testResponseConnControlEntityChunked.
@Test
public void testResponseConnControlEntityChunked() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
response.setEntity(new BasicHttpEntity(EmptyInputStream.INSTANCE, null, true));
final ResponseConnControl interceptor = new ResponseConnControl();
interceptor.process(response, response.getEntity(), context);
final Header header = response.getFirstHeader(HttpHeaders.CONNECTION);
Assertions.assertNull(header);
}
Aggregations