Package org.apache.http.entity

Examples of org.apache.http.entity.BufferedHttpEntity


        if (status > 299) {

            // Buffer response content
            final HttpEntity entity = response.getEntity();
            if (entity != null) {
                response.setEntity(new BufferedHttpEntity(entity));
            }

            this.managedConn.close();
            throw new TunnelRefusedException("CONNECT refused by proxy: " +
                    response.getStatusLine(), response);
View Full Code Here


        if (status > 299) {

            // Buffer response content
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                response.setEntity(new BufferedHttpEntity(entity));
            }

            this.managedConn.close();
            throw new TunnelRefusedException("CONNECT refused by proxy: " +
                    response.getStatusLine(), response);
View Full Code Here

            if(cr.getProperties().get(ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE) != null) {
                // TODO return InputStreamEntity
                return httpEntity;
            } else {
                return new BufferedHttpEntity(httpEntity);
            }
        } catch (Exception ex) {
            // TODO warning/error?
        }
View Full Code Here

      RequestHandle handle =
          (RequestHandle) context.removeAttribute("request-handle");
      HttpOperation op = (HttpOperation) context.removeAttribute("operation");

      try {
        response.setEntity(new BufferedHttpEntity(response.getEntity()));
      } catch(IOException ex) {
        throw new RuntimeException("Could not convert HttpEntity content.");
      }

      int statusCode = response.getStatusLine().getStatusCode();
View Full Code Here

                params.setParameter(nameValuePair.getName(), nameValuePair.getValue());
            }
            if (inputStream != null) {
                assert result instanceof HttpEntityEnclosingRequestBase;
                InputStreamEntity inputStreamEntity = new InputStreamEntity(inputStream, inputStream.available());
                ((HttpEntityEnclosingRequestBase)result).setEntity(new BufferedHttpEntity(inputStreamEntity));
            }

            return result;
        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

                params.setParameter(nameValuePair.getName(), nameValuePair.getValue());
            }
            if (inputStream != null) {
                assertTrue("Invalid request clazz (requires an entity)", result instanceof HttpEntityEnclosingRequestBase);
                InputStreamEntity inputStreamEntity = new InputStreamEntity(inputStream, inputStream.available());
                ((HttpEntityEnclosingRequestBase)result).setEntity(new BufferedHttpEntity(inputStreamEntity));
            }

            return result;
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

     *
     * @return A new BufferedHttpEntity wrapping the specified entity.
     */
    private HttpEntity newBufferedHttpEntity(HttpEntity entity) {
        try {
            return new BufferedHttpEntity(entity);
        } catch (IOException e) {
            throw new AmazonClientException("Unable to create HTTP entity: " + e.getMessage(), e);
        }
    }
View Full Code Here

            return responseBody;
        }

        if (hasHttpResponse() && httpResponse.getEntity() != null) {
            long now = System.nanoTime();
            HttpEntity bufferedEntity = new BufferedHttpEntity(httpResponse.getEntity());
            long contentLength = bufferedEntity.getContentLength();
            if (metrics != null) {
                metrics.setContentLength(contentLength);
            }

            InputStream instream = bufferedEntity.getContent();

            try {
                if (maxSize == 0 || (contentLength >= 0 && contentLength <= maxSize)) {
                    responseReadTime = System.nanoTime() - now;
                    responseBody = EntityUtils.toByteArray(bufferedEntity);
View Full Code Here

        // endless loop without it
        int counter = 0;
        byte[] content = null;

        if (httpResponse != null && httpResponse.getEntity() != null) {
            content = EntityUtils.toByteArray(new BufferedHttpEntity(httpResponse.getEntity()));
        }

        while (!aborted && content == null && counter < 10) {
            Thread.sleep(200);
            counter++;
View Full Code Here

        if (entity == null) {
                throw new ClientProtocolException("Response contains no content");
            }
       
        if (status >= 200 && status < 300) {
          entity = new BufferedHttpEntity(entity);
        } else {
          throw new HttpResponseException(status,phrase);
        }
        return entity;
      }
View Full Code Here

TOP

Related Classes of org.apache.http.entity.BufferedHttpEntity

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.