Examples of InputStreamEntity


Examples of org.apache.http.entity.InputStreamEntity

                            }

                            out.close();

                            byte[] arr = bytes.toByteArray();
                            response.setEntity(new InputStreamEntity(new ByteArrayInputStream(arr),
                                    arr.length));

                            return;
                        }
                    }
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

        return EntityUtils.toString(entity);
    }

    @Converter
    public static HttpEntity toEntity(InputStream is) {
        return new InputStreamEntity(is, -1);
    }
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

            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(HTTP.UTF_8) ;
            HttpEntity entity = reqEntity ;
            ((HttpEntityEnclosingRequestBase)httpRequest).setEntity(entity) ;
        }
        TypedInputStream ts = null ;
        // httpclient.getParams().setXXX
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

        HttpPost httppost = new HttpPost("http://localhost:8080" +
                "/servlets-examples/servlet/RequestInfoExample");

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

        InputStreamEntity reqEntity = new InputStreamEntity(
                new FileInputStream(file), -1);
        reqEntity.setContentType("binary/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

Examples of org.apache.http.entity.InputStreamEntity

        FaultyHttpClient client = new FaultyHttpClient();
        HttpContext context = new BasicHttpContext();

        String s = "http://localhost:" + port;
        HttpPost httppost = new HttpPost(s);
        httppost.setEntity(new InputStreamEntity(
                new ByteArrayInputStream(
                        new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ),
                        -1));

        try {
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

        clone = (HttpPost) httppost.clone();
        assertTrue(clone.getEntity() instanceof StringEntity);
        assertFalse(clone.getEntity().equals(e1));
       
        ByteArrayInputStream instream = new ByteArrayInputStream(new byte[] {});
        InputStreamEntity e2 = new InputStreamEntity(instream, -1);
        httppost.setEntity(e2);
       
        try {
            httppost.clone();
            fail("CloneNotSupportedException should have been thrown");
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

                    // 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

Examples of org.apache.http.entity.InputStreamEntity

    private static 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;
        if (!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

Examples of org.apache.http.entity.InputStreamEntity

    private static 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;
        if (!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

Examples of org.apache.http.entity.InputStreamEntity

    protected HttpResponse constructResponse(HttpResponse originalResponse,
            InputStream combinedStream) {
        HttpResponse response = new BasicHttpResponse(originalResponse.getProtocolVersion(),
                HttpStatus.SC_OK, "Success");

        HttpEntity entity = new InputStreamEntity(combinedStream, -1);
        response.setEntity(entity);
        response.setHeaders(originalResponse.getAllHeaders());

        return response;
    }
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.