Package org.apache.http

Examples of org.apache.http.HttpEntity


        Message in = exchange.getIn();
        if (in.getBody() == null) {
            return null;
        }

        HttpEntity answer = in.getBody(HttpEntity.class);
        if (answer == null) {
            try {
                Object data = in.getBody();
                if (data != null) {
                    String contentTypeString = ExchangeHelper.getContentType(exchange);
View Full Code Here


               testClassesSelector, methodName, "serialized"
       );
       log.debug("Ran test {} method {} at URL {}",
               new Object[] { testClassesSelector, methodName, remoteUrl });
      
       final HttpEntity entity = executor.getResponse().getEntity();
       if (entity != null) {
           try {
               final Object o = new ObjectInputStream(entity.getContent()).readObject();
               if( !(o instanceof ExecutionResult) ) {
                   throw new IllegalStateException("Expected an ExecutionResult, got a " + o.getClass().getName());
               }
               final ExecutionResult result = (ExecutionResult)o;
               if (result.isFailure()) {
                   throw result.getException();
               }
           } finally {
               entity.consumeContent();
           }
       }
   }
View Full Code Here

    mockInputStream = mock(InputStream.class);
    mockAuth = mock(Authentication.class);

    mockProcessor = mock(HosebirdMessageProcessor.class);

    HttpEntity mockHttpEntity = mock(HttpEntity.class);

    // set up required mocks to mock out all of the clientbase stuff
    when(mock.execute(any(HttpUriRequest.class)))
            .thenReturn(mockResponse);
    when(mockResponse.getStatusLine())
            .thenReturn(mockStatusLine);
    when(mockResponse.getEntity())
            .thenReturn(mockHttpEntity);
    when(mockHttpEntity.getContent())
            .thenReturn(mockInputStream);
  }
View Full Code Here

    when(httpClient.getConnectionManager()).thenReturn(connectionManager);

    StatusLine statusLine = Mockito.mock(StatusLine.class);
    when(statusLine.getStatusCode()).thenReturn(200);
   
    HttpEntity httpEntity = Mockito.mock(HttpEntity.class);
    when(httpEntity.getContent()).thenReturn(new ResourceUtil(responseURI).getInputStream());
   
    HttpResponse httpResponse = Mockito.mock(HttpResponse.class);
    when(httpResponse.getStatusLine()).thenReturn(statusLine);
    when(httpResponse.getEntity()).thenReturn(httpEntity);
   
View Full Code Here

    HttpUriRequest httpRequest = getHttpRequest(requestMethod, path, body, secureConnection, acceptType);
    HttpResponse httpResponse = httpClient.execute(httpRequest);

    UrlResponse urlResponse = new UrlResponse();
    urlResponse.status = httpResponse.getStatusLine().getStatusCode();
    HttpEntity entity = httpResponse.getEntity();
    if (entity != null) {
      urlResponse.body = EntityUtils.toString(entity);
    } else {
      urlResponse.body = "";
    }
View Full Code Here

    try {
      HttpPost httpPost = new HttpPost(getURI(params));
      httpPost.setEntity(new UrlEncodedFormEntity(params, CharSet.UTF8));
      HttpResponse response = httpClient.execute(httpPost);
      int statusCode = response.getStatusLine().getStatusCode();
      HttpEntity responseEntity = response.getEntity();
      String responseBody = EntityUtils.toString(responseEntity);
      EntityUtils.consume(responseEntity);
      LOG.debug("post responseBody: " + responseBody);
      wsResponse = (statusCode == 200) ?
          new WSResponse(responseBody) :
View Full Code Here

      this.response = response;
    }

    @Override
    public void close() throws IOException {
      HttpEntity httpEntity = response.getEntity();
      EntityUtils.consume(httpEntity);
    }
View Full Code Here

        // Now finally read in response body, up to targetLength bytes.
        // Note that entity might be null, for zero length responses.
        byte[] content = new byte[0];
        long readRate = 0;
        HttpEntity entity = response.getEntity();
        needAbort = true;

        if (entity != null) {
            InputStream in = null;

            try {
                in = entity.getContent();
                byte[] buffer = new byte[BUFFER_SIZE];
                int bytesRead = 0;
                int totalRead = 0;
                ByteArrayOutputStream out = new ByteArrayOutputStream(DEFAULT_BYTEARRAY_SIZE);
View Full Code Here

    this.request = request;
    this.response = response;
  }

  public String readAll() throws IOException {
    HttpEntity responseEntity = response.getEntity();

    InputStream contentStream = responseEntity.getContent();

    try {
      return IoUtils.readAll(contentStream);
    } finally {
      IoUtils.safeClose(contentStream);
View Full Code Here

    }
  }

  @Override
  public void serializeAsJson(OutputStream out) throws IOException {
    HttpEntity responseEntity = response.getEntity();

    InputStream contentStream = responseEntity.getContent();

    try {
      IoUtils.copyStream(contentStream, out);
    } finally {
      IoUtils.safeClose(contentStream);
View Full Code Here

TOP

Related Classes of org.apache.http.HttpEntity

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.