Package org.apache.http.impl.entity

Examples of org.apache.http.impl.entity.DefaultEntityDeserializer.deserialize()


        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);
View Full Code Here


        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
        }
    }
View Full Code Here

        message.addHeader(new Header("Content-Type", "unknown"));
        message.addHeader(new Header("Content-Length", "1"));
        message.addHeader(new Header("Content-Length", "yyy"));
        message.addHeader(new Header("Content-Length", "xxx"));
        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);
View Full Code Here

        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
        }
    }
View Full Code Here

        message.getParams().setBooleanParameter(HttpProtocolParams.STRICT_TRANSFER_ENCODING, false);
        message.addHeader(new Header("Content-Type", "unknown"));
        message.addHeader(new Header("Content-Length", "yyy"));
        message.addHeader(new Header("Content-Length", "xxx"));
        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);
View Full Code Here

        assertTrue(instream instanceof HttpDataInputStream);
       
        // 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
        }
    }
View Full Code Here

        // lenient mode
        message.getParams().setBooleanParameter(HttpProtocolParams.STRICT_TRANSFER_ENCODING, false);
        message.addHeader(new Header("Content-Type", "unknown"));
        message.addHeader(new Header("Content-Length", "xxx"));
        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);
View Full Code Here

        assertTrue(instream instanceof HttpDataInputStream);
       
        // 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
        }
    }
View Full Code Here

        HttpMessage message = new HttpMessageMockup();

        // lenient mode
        message.getParams().setBooleanParameter(HttpProtocolParams.STRICT_TRANSFER_ENCODING, false);
        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);
View Full Code Here

        HttpDataReceiver datareceiver = new HttpDataReceiverMockup(new byte[] {'0'});
        HttpMessage message = new HttpMessageMockup();

        message.addHeader(new Header("Content-Type", "stuff"));
        EntityDeserializer entitygen = new DefaultEntityDeserializer();
        HttpEntity entity = entitygen.deserialize(datareceiver, message);
        assertNotNull(entity);
        assertNotNull(entity.getContentType());
        assertEquals("stuff", entity.getContentType().getValue());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.