Examples of ChunkedOutputStream


Examples of org.apache.http.impl.io.ChunkedOutputStream

        assertEquals('\n', rawdata[13]);
    }

    public void testChunkedOutputStreamSmallChunk() throws IOException {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ChunkedOutputStream out = new ChunkedOutputStream(
            new HttpDataTransmitterMockup(buffer), 2);
        out.write('1')
        out.finish();
        out.close();
       
        byte [] rawdata =  buffer.toByteArray();
       
        assertEquals(11, rawdata.length);
        assertEquals('1', rawdata[0]);
View Full Code Here

Examples of org.apache.http.impl.io.ChunkedOutputStream

    protected OutputStream doSerialize(
            final HttpDataTransmitter datatransmitter,
            final HttpMessage message) throws HttpException, IOException {
        long len = this.lenStrategy.determineLength(message);
        if (len == ContentLengthStrategy.CHUNKED) {
            return new ChunkedOutputStream(datatransmitter);
        } else if (len == ContentLengthStrategy.IDENTITY) {
            return new IdentityOutputStream(datatransmitter);
        } else {
            return new ContentLengthOutputStream(datatransmitter, len);
        }
View Full Code Here

Examples of org.apache.http.impl.io.ChunkedOutputStream

            // expected
        }
    }

    public void testChunkedOutputStreamClose() throws IOException {
        ChunkedOutputStream out = new ChunkedOutputStream(
                new HttpDataTransmitterMockup());
        out.close();
        out.close();
        try {
          out.write(new byte[] {1,2,3});
            fail("IOException should have been thrown");
        } catch (IOException ex) {
            // expected
        }
        try {
            out.write(1);
            fail("IOException should have been thrown");
        } catch (IOException ex) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.http.impl.io.ChunkedOutputStream

    }
   
    public void testChunkedConsitance() throws IOException {
        String input = "76126;27823abcd;:q38a-\nkjc\rk%1ad\tkh/asdui\r\njkh+?\\suweb";
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        OutputStream out = new ChunkedOutputStream(new HttpDataTransmitterMockup(buffer));
        out.write(EncodingUtils.getBytes(input, CONTENT_CHARSET));
        out.flush();
        out.close();
        out.close();
        buffer.close();
        InputStream in = new ChunkedInputStream(
                new HttpDataReceiverMockup(
                        buffer.toByteArray()));
View Full Code Here

Examples of org.apache.http.impl.io.ChunkedOutputStream

        assertEquals(input, output);
    }

    public void testChunkedOutputStream() throws IOException {
      HttpDataTransmitterMockup buffer = new HttpDataTransmitterMockup();
        ChunkedOutputStream out = new ChunkedOutputStream(buffer, 2);
        out.write('1')
        out.write('2')
        out.write('3')
        out.write('4')
        out.finish();
        out.close();
       
        byte [] rawdata =  buffer.getData();
       
        assertEquals(19, rawdata.length);
        assertEquals('2', rawdata[0]);
View Full Code Here

Examples of org.apache.http.impl.io.ChunkedOutputStream

        assertEquals('\n', rawdata[18]);
    }

    public void testChunkedOutputStreamLargeChunk() throws IOException {
      HttpDataTransmitterMockup buffer = new HttpDataTransmitterMockup();
        ChunkedOutputStream out = new ChunkedOutputStream(buffer, 2);
        out.write(new byte[] {'1', '2', '3', '4'});
        out.finish();
        out.close();
       
        byte [] rawdata =  buffer.getData();
       
        assertEquals(14, rawdata.length);
        assertEquals('4', rawdata[0]);
View Full Code Here

Examples of org.apache.http.impl.io.ChunkedOutputStream

        assertEquals('\n', rawdata[13]);
    }

    public void testChunkedOutputStreamSmallChunk() throws IOException {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ChunkedOutputStream out = new ChunkedOutputStream(
            new HttpDataTransmitterMockup(buffer), 2);
        out.write('1')
        out.finish();
        out.close();
       
        byte [] rawdata =  buffer.toByteArray();
       
        assertEquals(11, rawdata.length);
        assertEquals('1', rawdata[0]);
View Full Code Here

Examples of org.apache.http.impl.io.ChunkedOutputStream

    protected OutputStream doSerialize(
            final HttpDataTransmitter datatransmitter,
            final HttpMessage message) throws HttpException, IOException {
        long len = this.lenStrategy.determineLength(message);
        if (len == ContentLengthStrategy.CHUNKED) {
            return new ChunkedOutputStream(datatransmitter);
        } else if (len == ContentLengthStrategy.IDENTITY) {
            return new IdentityOutputStream(datatransmitter);
        } else {
            return new ContentLengthOutputStream(datatransmitter, len);
        }
View Full Code Here

Examples of org.apache.http.impl.io.ChunkedOutputStream

            // expected
        }
    }

    public void testChunkedOutputStreamClose() throws IOException {
        ChunkedOutputStream out = new ChunkedOutputStream(
                new SessionOutputBufferMockup());
        out.close();
        out.close();
        try {
            out.write(new byte[] {1,2,3});
            fail("IOException should have been thrown");
        } catch (IOException ex) {
            // expected
        }
        try {
            out.write(1);
            fail("IOException should have been thrown");
        } catch (IOException ex) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.http.io.ChunkedOutputStream

                if (message.getHttpVersion().lessEquals(HttpVersion.HTTP_1_0)) {
                    throw new ProtocolException(
                            "Chunked transfer encoding not allowed for " +
                            message.getHttpVersion());
                }
                return new ChunkedOutputStream(datatransmitter);
            } else if (HTTP.IDENTITY_CODING.equalsIgnoreCase(s)) {
                return new IdentityOutputStream(datatransmitter);
            } else {
                throw new ProtocolException(
                        "Unsupported transfer encoding: " + s);
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.