use of org.apache.hc.core5.http.impl.DefaultContentLengthStrategy in project httpcomponents-core by apache.
the class TestDefaultContentLengthStrategy method testEntityWithChunkTransferEncoding.
@Test
public void testEntityWithChunkTransferEncoding() throws Exception {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Transfer-Encoding", "Chunked");
Assertions.assertEquals(ContentLengthStrategy.CHUNKED, lenStrategy.determineLength(message));
}
use of org.apache.hc.core5.http.impl.DefaultContentLengthStrategy in project httpcomponents-core by apache.
the class TestDefaultContentLengthStrategy method testEntityWithNegativeContentLength.
@Test
public void testEntityWithNegativeContentLength() throws Exception {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Content-Length", "-10");
Assertions.assertThrows(ProtocolException.class, () -> lenStrategy.determineLength(message));
}
use of org.apache.hc.core5.http.impl.DefaultContentLengthStrategy in project httpcomponents-core by apache.
the class TestDefaultContentLengthStrategy method testEntityNoContentDelimiter.
@Test
public void testEntityNoContentDelimiter() throws Exception {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
Assertions.assertEquals(ContentLengthStrategy.UNDEFINED, lenStrategy.determineLength(message));
}
use of org.apache.hc.core5.http.impl.DefaultContentLengthStrategy in project httpcomponents-core by apache.
the class TestDefaultContentLengthStrategy method testEntityWithInvalidTransferEncoding.
@Test
public void testEntityWithInvalidTransferEncoding() throws Exception {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Transfer-Encoding", "whatever");
Assertions.assertThrows(ProtocolException.class, () -> lenStrategy.determineLength(message));
}
use of org.apache.hc.core5.http.impl.DefaultContentLengthStrategy in project httpcomponents-core by apache.
the class TestDefaultContentLengthStrategy method testEntityWithIdentityTransferEncoding.
@Test
public void testEntityWithIdentityTransferEncoding() throws Exception {
final ContentLengthStrategy lenStrategy = new DefaultContentLengthStrategy();
final HttpMessage message = new TestHttpMessage();
message.addHeader("Transfer-Encoding", "Identity");
Assertions.assertThrows(NotImplementedException.class, () -> lenStrategy.determineLength(message));
}
Aggregations