Package org.apache.http

Examples of org.apache.http.HttpMessage.addHeader()


    public void testEntityContentType() throws Exception {
        SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
        HttpMessage message = new HttpMessageMockup();

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


    public void testEntityContentEncoding() throws Exception {
        SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
        HttpMessage message = new HttpMessageMockup();

        message.addHeader("Content-Encoding", "what not");
        EntityDeserializer entitygen = new EntityDeserializer(
                new LaxContentLengthStrategy());
        HttpEntity entity = entitygen.deserialize(datareceiver, message);
        assertNotNull(entity);
        assertNotNull(entity.getContentEncoding());
View Full Code Here

    }

    public void testEntityWithChunkTransferEncoding() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "Chunked");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
        assertNotNull(outstream);
View Full Code Here

    }

    public void testEntityWithIdentityTransferEncoding() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "Identity");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
        assertNotNull(outstream);
View Full Code Here

    }
   
    public void testEntityWithInvalidTransferEncoding() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "whatever");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        try {
            entitywriter.doSerialize(datatransmitter, message);
View Full Code Here

    public void testEntityWithInvalidChunkEncodingAndHTTP10() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
                HttpVersion.HTTP_1_0);
        message.addHeader("Transfer-Encoding", "chunked");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        try {
            entitywriter.doSerialize(datatransmitter, message);
View Full Code Here

    }
   
    public void testEntityWithContentLength() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Content-Length", "100");
        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
        assertNotNull(outstream);
        assertTrue(outstream instanceof ContentLengthOutputStream);
View Full Code Here

    }
   
    public void testEntityWithInvalidContentLength() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Content-Length", "whatever");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        try {
            entitywriter.doSerialize(datatransmitter, message);
View Full Code Here

        byte[] content = new byte[] {1, 2, 3, 4, 5};
        ByteArrayEntity entity = new ByteArrayEntity(content);
       
        SessionOutputBufferMockup datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Content-Length", Integer.toString(content.length));
       
        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        entitywriter.serialize(datatransmitter, message, entity);
       
View Full Code Here

    }
   
    public void testEntityWithInvalidContentLength() throws Exception {
        ContentLengthStrategy lenStrategy = new StrictContentLengthStrategy();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Content-Length", "whatever");

        try {
            lenStrategy.determineLength(message);
            fail("ProtocolException should have been thrown");
        } catch (ProtocolException ex) {
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.