Package org.apache.http.entity

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


        HttpEntityEnclosingRequestBase enclosingMethod = ("POST".equals(methodType))
          ? new HttpPost(requestUri)
          : new HttpPut(requestUri);

        if (request.getPostBodyLength() > 0) {
          enclosingMethod.setEntity(new InputStreamEntity(request.getPostBody(), request.getPostBodyLength()));
        }
        httpMethod = enclosingMethod;
      } else if ("GET".equals(methodType)) {
        httpMethod = new HttpGet(requestUri);
      } else if ("HEAD".equals(methodType)) {
View Full Code Here

    try {
      in = fs.open(path);
    } catch (IOException e) {
      throw new ServiceUnavailableException(e);
    }
    return new InputStreamEntity(in, -1);
  }
View Full Code Here

        final HttpContext context = new BasicHttpContext();

        final String s = "http://localhost:" + port;
        final 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

        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();

        final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
        final HttpPut httpput = new HttpPut("/");
        httpput.setConfig(config);
        httpput.setEntity(new InputStreamEntity(
                new ByteArrayInputStream(
                        new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ),
                        -1));

        final HttpResponse response = this.httpclient.execute(getServerHttp(), httpput);
View Full Code Here

        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();

        final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
        final HttpPut httpput = new HttpPut("/");
        httpput.setConfig(config);
        httpput.setEntity(new InputStreamEntity(
                new ByteArrayInputStream(
                        new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ),
                        -1));

        try {
View Full Code Here

                new UsernamePasswordCredentials("test", "test"));

        this.httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();

        final 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);
            Assert.fail("ClientProtocolException should have been thrown");
View Full Code Here

    @Test
    public void testGzipDecompressingEntityDoesNotCrashInConstructorAndLeaveInputStreamOpen()
            throws Exception {
        final AtomicBoolean inputStreamIsClosed = new AtomicBoolean(false);
        final HttpEntity in = new InputStreamEntity(new InputStream() {
            @Override
            public int read() throws IOException {
                throw new IOException("An exception occurred");
            }
View Full Code Here

    public Request bodyByteArray(final byte[] b, final int off, final int len) {
        return body(new ByteArrayEntity(b, off, len));
    }

    public Request bodyStream(final InputStream instream) {
        return body(new InputStreamEntity(instream, -1));
    }
View Full Code Here

    public Request bodyStream(final InputStream instream) {
        return body(new InputStreamEntity(instream, -1));
    }

    public Request bodyStream(final InputStream instream, final ContentType contentType) {
        return body(new InputStreamEntity(instream, -1, contentType));
    }
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.