Examples of IdentityOutputStream


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

    }

    public void testClose() throws Exception {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      SessionOutputBufferMockup datatransmitter = new SessionOutputBufferMockup(buffer);
      OutputStream out = new IdentityOutputStream(datatransmitter);
      out.close();
      out.close();
        byte[] tmp = new byte[10];
        try {
          out.write(tmp);
            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.IdentityOutputStream

        }
    }
   
    public void testConstructor() throws Exception {
        SessionOutputBufferMockup transmitter = new SessionOutputBufferMockup();
        new IdentityOutputStream(transmitter);
        try {
            new IdentityOutputStream(null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            //expected
        }
    }
View Full Code Here

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

        }
    }
   
    public void testBasicWrite() throws Exception {
        SessionOutputBufferMockup transmitter = new SessionOutputBufferMockup();
        IdentityOutputStream outstream = new IdentityOutputStream(transmitter);
        outstream.write(new byte[] {'a', 'b'}, 0, 2);
        outstream.write('c');
        outstream.flush();
       
        byte[] input = transmitter.getData();
       
        assertNotNull(input);
        byte[] expected = new byte[] {'a', 'b', 'c'};
View Full Code Here

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

        }
    }
   
    public void testClosedCondition() throws Exception {
        SessionOutputBufferMockup transmitter = new SessionOutputBufferMockup();
        IdentityOutputStream outstream = new IdentityOutputStream(transmitter);
        outstream.close();
        outstream.close();
       
        try {
            byte[] tmp = new byte[2];
            outstream.write(tmp, 0, tmp.length);
            fail("IOException should have been thrown");
        } catch (IOException e) {
            //expected
        }
        try {
            outstream.write('a');
            fail("IOException should have been thrown");
        } catch (IOException e) {
            //expected
        }
    }
View Full Code Here

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

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

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

            final long len,
            final SessionOutputBuffer outbuffer) {
        if (len == ContentLengthStrategy.CHUNKED) {
            return new ChunkedOutputStream(2048, outbuffer);
        } else if (len == ContentLengthStrategy.IDENTITY) {
            return new IdentityOutputStream(outbuffer);
        } else {
            return new ContentLengthOutputStream(outbuffer, len);
        }
    }
View Full Code Here

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

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

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

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

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

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

Examples of org.apache.http.io.IdentityOutputStream

                            "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);
            }
        } else if (contentLengthHeader != null) {
            String s = contentLengthHeader.getValue();
            try {
                long len = Long.parseLong(s);
                return new ContentLengthOutputStream(datatransmitter, len);
            } catch (NumberFormatException e) {
                throw new ProtocolException("Invalid content length: " + s);
            }
        } else {
            return new IdentityOutputStream(datatransmitter);
        }
    }
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.