Examples of InputStreamEntity


Examples of org.apache.http.entity.InputStreamEntity

            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

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

                this.buffer.shutdown();
                finished = true;
            }
            if (finished) {
                this.response.setEntity(
                        new InputStreamEntity(new ContentInputStream(this.buffer), -1));
            }
        }
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);
                        answer = new InputStreamEntity(in.getBody(InputStream.class), -1);
                        if (contentType != null) {
                            ((InputStreamEntity)answer).setContentType(contentType);
                        }
                    }
                }
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

        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

Examples of org.apache.http.entity.InputStreamEntity

        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

Examples of org.apache.http.entity.InputStreamEntity

      // The code bellow shows a workaround, although we should avoid that
      if(false) {
        if(length<0) {
          ByteStreamCache bs = new ByteStreamCache();
          bs.copyFrom(request.getInputStream());
          HttpEntity payloadEntity = new InputStreamEntity(bs.getInputStream(), bs.getLength());
          ((HttpEntityEnclosingRequest) method).setEntity(payloadEntity);
          return method;
        }
      }
      // Regular code
      HttpEntity payloadEntity = new InputStreamEntity(request.getInputStream(), length);
      ((HttpEntityEnclosingRequest) method).setEntity(payloadEntity);
    }catch(Exception e){
      throw new ServletException("Error while parsing the payload");
    }
    return method;
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

      this(name, stream, length, BINARY_OCTET_STREAM);
    }

    @Override
    protected HttpEntity createEntity() throws ClientServicesException {
      InputStreamEntity inputStreamEntity = new InputStreamEntity(stream, length);
      inputStreamEntity.setContentEncoding(BINARY);
      if (length == -1) {
        inputStreamEntity.setChunked(true);
      }

      return inputStreamEntity;
    }
View Full Code Here

Examples of org.apache.http.entity.InputStreamEntity

    final HttpClient httpclient = new DefaultHttpClient();
    final HttpUriRequest httpurirequest;

    final HttpPost httppost = new HttpPost(url);
    httppost.setHeader("Accept", requestHeader);
    final InputStreamEntity ise = new InputStreamEntity(stream,-1);
    httppost.setEntity(ise);
    httpurirequest = httppost;

    final HttpResponse response = httpclient.execute(httpurirequest);
    final HttpEntity entity = response.getEntity();
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.