use of org.apache.hc.core5.http.impl.DefaultContentLengthStrategy in project httpcomponents-core by apache.
the class TestDefaultContentLengthStrategy method testEntityWithContentLength.
@Test
public void testEntityWithContentLength() throws Exception {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Content-Length", "100");
Assertions.assertEquals(100, lenStrategy.determineLength(message));
}
use of org.apache.hc.core5.http.impl.DefaultContentLengthStrategy in project httpcomponents-core by apache.
the class TestDefaultContentLengthStrategy method testEntityWithInvalidContentLength.
@Test
public void testEntityWithInvalidContentLength() throws Exception {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Content-Length", "whatever");
Assertions.assertThrows(ProtocolException.class, () -> lenStrategy.determineLength(message));
}
Aggregations