Package org.apache.http.io

Examples of org.apache.http.io.HttpDataReceiver


            "header3: stuff\r\n" +
            "     and more stuff\r\n" +
            "\t and even more stuff\r\n"
            "     \r\n"
            "\r\n";
        HttpDataReceiver receiver = new HttpDataReceiverMockup(s, "US-ASCII");
        Header[] headers = Header.parseAll(receiver);
        assertNotNull(headers);
        assertEquals(3, headers.length);
        assertEquals("header1", headers[0].getName());
        assertEquals("stuff", headers[0].getValue());
View Full Code Here


    public void testBufferedHeader() throws Exception {
        String s =
            "header1  : stuff; param1 = value1; param2 = \"value 2\" \r\n" +
            "\r\n";
        HttpDataReceiver receiver = new HttpDataReceiverMockup(s, "US-ASCII");
        Header[] headers = Header.parseAll(receiver);
        assertNotNull(headers);
        assertEquals(1, headers.length);
        assertEquals("header1  : stuff; param1 = value1; param2 = \"value 2\" ", headers[0].toString());
        HeaderElement[] elements = headers[0].getElements();
View Full Code Here

    public void testParsingInvalidHeaders() throws Exception {
        String s = "    stuff\r\n" +
            "header1: stuff\r\n" +
            "\r\n";
        HttpDataReceiver receiver = new HttpDataReceiverMockup(s, "US-ASCII");
        try {
            Header.parseAll(receiver);
            fail("ProtocolException should have been thrown");
        } catch (ProtocolException ex) {
            // expected
View Full Code Here

   
    public void testParsingMalformedFirstHeader() throws Exception {
        String s =
            "    header1: stuff\r\n" +
            "header2  : stuff \r\n";
        HttpDataReceiver receiver = new HttpDataReceiverMockup(s, "US-ASCII");
        Header[] headers = Header.parseAll(receiver);
        assertNotNull(headers);
        assertEquals(2, headers.length);
        assertEquals("header1", headers[0].getName());
        assertEquals("stuff", headers[0].getValue());
View Full Code Here

        assertEquals("stuff", headers[1].getValue());
    }
   
    public void testEmptyDataStream() throws Exception {
        String s = "";
        HttpDataReceiver receiver = new HttpDataReceiverMockup(s, "US-ASCII");
        Header[] headers = Header.parseAll(receiver);
        assertNotNull(headers);
        assertEquals(0, headers.length);
    }
View Full Code Here

            // expected
        }
    }

    public void testEntityWithTransferEncoding() throws Exception {
        HttpDataReceiver datareceiver = new HttpDataReceiverMockup("0\r\n", "US-ASCII");
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(HttpProtocolParams.STRICT_TRANSFER_ENCODING, false);
        message.addHeader(new Header("Content-Type", "unknown"));
View Full Code Here

        assertTrue(entity.isChunked());
        assertTrue(entity.getContent() instanceof ChunkedInputStream);
    }

    public void testEntityWithIdentityTransferEncoding() throws Exception {
        HttpDataReceiver datareceiver =
          new HttpDataReceiverMockup(new byte[] {});
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(HttpProtocolParams.STRICT_TRANSFER_ENCODING, false);
View Full Code Here

        assertEquals(-1, entity.getContentLength());
        assertFalse(entity.isChunked());
    }

    public void testEntityWithUnsupportedTransferEncoding() throws Exception {
        HttpDataReceiver datareceiver = new HttpDataReceiverMockup("0\r\n", "US-ASCII");
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(HttpProtocolParams.STRICT_TRANSFER_ENCODING, false);
        message.addHeader(new Header("Content-Type", "unknown"));
View Full Code Here

            // expected
        }
    }

    public void testChunkedTransferEncodingMustBeLast() throws Exception {
        HttpDataReceiver datareceiver = new HttpDataReceiverMockup("0\r\n", "US-ASCII");
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(HttpProtocolParams.STRICT_TRANSFER_ENCODING, false);
        message.addHeader(new Header("Content-Type", "unknown"));
View Full Code Here

            // expected
        }
    }

    public void testEntityWithContentLength() throws Exception {
        HttpDataReceiver datareceiver = new HttpDataReceiverMockup(new byte[] {});
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(HttpProtocolParams.STRICT_TRANSFER_ENCODING, false);
        message.addHeader(new Header("Content-Type", "unknown"));
View Full Code Here

TOP

Related Classes of org.apache.http.io.HttpDataReceiver

Copyright © 2018 www.massapicom. 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.