Package org.apache.http.entity

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


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

        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

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

      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

    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

     * @param authenticator
     *            HTTP Authenticator
     */
    public static void execHttpPost(String url, String contentType, InputStream input, long length, String acceptType,
            HttpResponseHandler handler, HttpClient httpClient, HttpContext httpContext, HttpAuthenticator authenticator) {
        InputStreamEntity e = new InputStreamEntity(input, length);
        e.setContentType(contentType);
        e.setContentEncoding("UTF-8");
        try {
            execHttpPost(url, e, acceptType, handler, httpClient, httpContext, authenticator);
        } finally {
            closeEntity(e);
        }
View Full Code Here

     * @param authenticator
     *            HTTP Authenticator
     */
    public static void execHttpPut(String url, String contentType, InputStream input, long length, HttpClient httpClient,
            HttpContext httpContext, HttpAuthenticator authenticator) {
        InputStreamEntity e = new InputStreamEntity(input, length);
        e.setContentType(contentType);
        e.setContentEncoding("UTF-8");
        try {
            execHttpPut(url, e, httpClient, httpContext, authenticator);
        } finally {
            closeEntity(e);
        }
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.