assertTrue(entity.getContent() instanceof ContentLengthInputStream);
}
public void testEntityWithMultipleContentLength() throws Exception {
HttpDataReceiver datareceiver = new HttpDataReceiverMockup(new byte[] {'0'});
HttpMessage message = new HttpMessageMockup();
// lenient mode
message.getParams().setBooleanParameter(HttpProtocolParams.STRICT_TRANSFER_ENCODING, false);
message.addHeader(new Header("Content-Type", "unknown"));
message.addHeader(new Header("Content-Length", "0"));
message.addHeader(new Header("Content-Length", "0"));
message.addHeader(new Header("Content-Length", "1"));
EntityDeserializer entitygen = new DefaultEntityDeserializer();
HttpEntity entity = entitygen.deserialize(datareceiver, message);
assertNotNull(entity);
assertEquals(1, entity.getContentLength());
assertFalse(entity.isChunked());
InputStream instream = entity.getContent();
assertNotNull(instream);
assertTrue(instream instanceof ContentLengthInputStream);
// strict mode
message.getParams().setBooleanParameter(HttpProtocolParams.STRICT_TRANSFER_ENCODING, true);
try {
entitygen.deserialize(datareceiver, message);
fail("ProtocolException should have been thrown");
} catch (ProtocolException ex) {
// expected