Examples of ContentLengthInputStream


Examples of org.apache.commons.httpclient.ContentLengthInputStream

            else if (contentLength != null)
            {
                long len = getContentLength();
                if (len >= 0)
                {
                    in = new ContentLengthInputStream(in, len);
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

                else if (contentLength != null)
                {
                    long len = getContentLength();
                    if (len >= 0)
                    {
                        in = new ContentLengthInputStream(in, len);
                    }
                }
                this.entity = in;
            }
        }
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

                        in = new ChunkedInputStream(in);
                    }
                } else if (contentLength != null) {
                    long len = getContentLength();
                    if (len >= 0) {
                        in = new ContentLengthInputStream(in, len);
                    }
                }
                this.entity = in;
            }
        }
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

                    in = new ChunkedInputStream(in);
                }
            } else if (contentLength != null) {
                long len = getContentLength();
                if (len >= 0) {
                    in = new ContentLengthInputStream(in, len);
                }
            }
            this.entity = in;
        }
    }
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

            outstream = new ChunkedOutputStream(outstream);
        }
        if (contentLength >= 0) {
            // don't need a watcher here - we're reading from something local,
            // not server-side.
            instream = new ContentLengthInputStream(instream, contentLength);
        }

        byte[] tmp = new byte[4096];
        int total = 0;
        int i = 0;
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

                    }
                } else if (contentLength != null) {
                    long len = getContentLength();

                    if (len >= 0) {
                        in = new ContentLengthInputStream(in, len);
                    }
                }

                this.entity = in;
            }
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

                }
            } else if (contentLength != null) {
                long len = getContentLength();

                if (len >= 0) {
                    in = new ContentLengthInputStream(in, len);
                }
            }

            this.entity = in;
        }
View Full Code Here

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

    }

    private static final String CONTENT_CHARSET = "ISO-8859-1";
       
    public void testConstructors() throws Exception {
        new ContentLengthInputStream(new SessionInputBufferMockup(new byte[] {}), 10);
        try {
            new ContentLengthInputStream(null, 10);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            new ContentLengthInputStream(new SessionInputBufferMockup(new byte[] {}), -10);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

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

        }
    }

    public void testBasics() throws IOException {
        String correct = "1234567890123456";
        InputStream in = new ContentLengthInputStream(new SessionInputBufferMockup(
            EncodingUtils.getBytes(correct, CONTENT_CHARSET)), 10L);
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        byte[] buffer = new byte[50];
        int len = in.read(buffer, 0, 2);
        out.write(buffer, 0, len);
        len = in.read(buffer);
        out.write(buffer, 0, len);
       
        String result = EncodingUtils.getString(out.toByteArray(), CONTENT_CHARSET);
        assertEquals(result, "1234567890");
    }
View Full Code Here

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

        String result = EncodingUtils.getString(out.toByteArray(), CONTENT_CHARSET);
        assertEquals(result, "1234567890");
    }

    public void testSkip() throws IOException {
        InputStream in = new ContentLengthInputStream(new SessionInputBufferMockup(new byte[20]), 10L);
        assertEquals(10, in.skip(10));
        assertTrue(in.read() == -1);

        in = new ContentLengthInputStream(new SessionInputBufferMockup(new byte[20]), 10L);
        in.read();
        assertEquals(9, in.skip(10));
        assertTrue(in.read() == -1);

        in = new ContentLengthInputStream(new SessionInputBufferMockup(new byte[20]), 2L);
        in.read();
        in.read();
        assertTrue(in.skip(10) <= 0);
        assertTrue(in.skip(-1) == 0);
        assertTrue(in.read() == -1);
       
        in = new ContentLengthInputStream(new SessionInputBufferMockup(new byte[2]), 4L);
        in.read();
        assertTrue(in.skip(2) == 1);
    }
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.