Package org.apache.http.entity

Examples of org.apache.http.entity.InputStreamEntity


    private HttpEntity asHttpEntity(InputStream in, Exchange exchange) throws IOException {
        String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
        String contentType = ExchangeHelper.getContentType(exchange);

        InputStreamEntity entity = null;
        if (exchange == null
            || !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
            entity = new InputStreamEntity(GZIPHelper.compressGzip(contentEncoding, in), -1);       
        } else {
            entity = new InputStreamEntity(in, -1);
        }
        entity.setContentEncoding(contentEncoding);
        entity.setContentType(contentType);
        return entity;
    }
View Full Code Here


    private HttpEntity asHttpEntity(byte[] data, Exchange exchange) throws Exception {
        String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
        String contentType = ExchangeHelper.getContentType(exchange);

        InputStreamEntity entity = null;
        if (exchange == null
            || !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
            entity = new InputStreamEntity(GZIPHelper.compressGzip(contentEncoding, data), -1);       
        } else {
            entity = new InputStreamEntity(new ByteArrayInputStream(data), -1);
        }
        entity.setContentEncoding(contentEncoding);
        entity.setContentType(contentType);

        return entity;
    }
View Full Code Here

                    // fallback as input stream
                    if (answer == null) {
                        // force the body as an input stream since this is the fallback
                        InputStream is = in.getMandatoryBody(InputStream.class);
                        InputStreamEntity entity = new InputStreamEntity(is, -1);
                        entity.setContentType(contentType);
                        answer = entity;
                    }
                }
            } catch (UnsupportedEncodingException e) {
                throw new CamelExchangeException("Error creating RequestEntity from message body", exchange, e);
View Full Code Here

            }

            public HttpRequest submitRequest( HttpContext context ) {
                HttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/");
                post.setHeader( "Connection", "Close" );
                post.setEntity(new InputStreamEntity(producer, 1));
                return post;
            }

            public void handleResponse(final HttpResponse response, final HttpContext context) {
            }
View Full Code Here

    private HttpEntity makeStreamingEntity() {
        byte[] body = HttpTestUtils.getRandomBytes(101);
        ByteArrayInputStream buf = new ByteArrayInputStream(body);
        cis = new ConsumableInputStream(buf);
        return new InputStreamEntity(cis, 101);
    }
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

            HttpEntity[] requestBodies = {
                    new StringEntity(
                            "This is the first test request", "UTF-8"),
                    new ByteArrayEntity(
                            "This is the second test request".getBytes("UTF-8")),
                    new InputStreamEntity(
                            new ByteArrayInputStream(
                                    "This is the third test request (will be chunked)"
                                    .getBytes("UTF-8")), -1)
            };
           
View Full Code Here

            ByteArrayOutputStream out = new ByteArrayOutputStream() ;
            Model model = ModelFactory.createModelForGraph(graphToSend) ;
            model.write(out, "RDF/XML") ;
            byte[] bytes = out.toByteArray() ;
            ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()) ;
            InputStreamEntity reqEntity = new InputStreamEntity(in, bytes.length) ;
            reqEntity.setContentType(WebContent.contentTypeRDFXML) ;
            reqEntity.setContentEncoding(WebContent.charsetUTF8) ;
            HttpEntity entity = reqEntity ;
            ((HttpEntityEnclosingRequestBase)httpRequest).setEntity(entity) ;
        }
        TypedInputStream ts = null ;
        // httpclient.getParams().setXXX
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.