Package org.apache.http.entity

Examples of org.apache.http.entity.InputStreamEntity


        setMinimalResponseHeaders(resp);
        resp.setHeader("Content-Length","" + nbytes);

        final Flag closed = new Flag();
        final ByteArrayInputStream bais = makeTrackableBody(nbytes, closed);
        resp.setEntity(new InputStreamEntity(bais, -1));

        impl.ensureProtocolCompliance(wrapper, resp);
        assertNull(resp.getEntity());
        assertTrue(closed.set || bais.read() == -1);
    }
View Full Code Here


        final int nbytes = 128;
        final HttpResponse resp = makePartialResponse(nbytes);

        final Flag closed = new Flag();
        final ByteArrayInputStream bais = makeTrackableBody(nbytes, closed);
        resp.setEntity(new InputStreamEntity(bais, -1));

        try {
            impl.ensureProtocolCompliance(wrapper, resp);
        } catch (final ClientProtocolException expected) {
        }
View Full Code Here

        final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);

        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_CONTINUE, "Continue");
        final Flag closed = new Flag();
        final ByteArrayInputStream bais = makeTrackableBody(nbytes, closed);
        resp.setEntity(new InputStreamEntity(bais, -1));

        try {
            impl.ensureProtocolCompliance(wrapper, resp);
        } catch (final ClientProtocolException expected) {
        }
View Full Code Here

        final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
        final HttpResponse resp2 = HttpTestUtils.make500Response();
        final byte[] body = HttpTestUtils.getRandomBytes(101);
        final ByteArrayInputStream buf = new ByteArrayInputStream(body);
        final ConsumableInputStream cis = new ConsumableInputStream(buf);
        final HttpEntity entity = new InputStreamEntity(cis, 101);
        resp2.setEntity(entity);

        backendExpectsAnyRequestAndReturn(resp2);

        replayMocks();
View Full Code Here

        final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
                "http://foo.example.com"));

        final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
                HttpStatus.SC_OK, "OK");
        resp1.setEntity(new InputStreamEntity(new InputStream() {
            private boolean closed = false;

            @Override
            public void close() throws IOException {
                closed = true;
View Full Code Here

        try {
            HttpPost httppost = new HttpPost("http://localhost/");

            File file = new File(args[0]);

            InputStreamEntity reqEntity = new InputStreamEntity(
                    new FileInputStream(file), -1, ContentType.APPLICATION_OCTET_STREAM);
            reqEntity.setChunked(true);
            // It may be more appropriate to use FileEntity class in this particular
            // instance but we are using a more generic InputStreamEntity to demonstrate
            // the capability to stream out data from any arbitrary source
            //
            // FileEntity entity = new FileEntity(file, "binary/octet-stream");
View Full Code Here

            httpRequest = new HttpPost(proxyTargetURL);
            long contentLength = NumberUtils.toLong(request.getHeader(HTTP.CONTENT_LEN));
           
            if (contentLength > 0L)
            {
                HttpEntity entity = new InputStreamEntity(request.getInputStream(), contentLength);
                ((HttpPost) httpRequest).setEntity(entity);
            }
        }
        else if (HttpPut.METHOD_NAME.equals(method))
        {
            httpRequest = new HttpPut(proxyTargetURL);
           
            long contentLength = NumberUtils.toLong(request.getHeader(HTTP.CONTENT_LEN));
           
            if (contentLength > 0L)
            {
                HttpEntity entity = new InputStreamEntity(request.getInputStream(), contentLength);
                ((HttpPost) httpRequest).setEntity(entity);
            }
        }
        else if (HttpDelete.METHOD_NAME.equals(method))
        {
View Full Code Here


        this.httpclient.setCredentialsProvider(credsProvider);

        HttpPut httpput = new HttpPut("/");
        httpput.setEntity(new InputStreamEntity(
                new ByteArrayInputStream(
                        new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ),
                        -1));
        httpput.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
View Full Code Here


        this.httpclient.setCredentialsProvider(credsProvider);

        HttpPut httpput = new HttpPut("/");
        httpput.setEntity(new InputStreamEntity(
                new ByteArrayInputStream(
                        new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ),
                        -1));
        httpput.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
View Full Code Here


        this.httpclient.setCredentialsProvider(credsProvider);

        HttpPost httppost = new HttpPost("/");
        httppost.setEntity(new InputStreamEntity(
                new ByteArrayInputStream(
                        new byte[] { 0,1,2,3,4,5,6,7,8,9 }), -1));

        try {
            this.httpclient.execute(getServerHttp(), httppost);
View Full Code Here

TOP

Related Classes of org.apache.http.entity.InputStreamEntity

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.