org.apache.hc.client5.http.fluent

## Class ContentResponseHandler

- java.lang.Object
- - org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler<Content>
  - - org.apache.hc.client5.http.fluent.ContentResponseHandler

- All Implemented Interfaces:
    HttpClientResponseHandler<Content>

      public class ContentResponseHandler
      extends AbstractHttpClientResponseHandler<Content>

  `HttpClientResponseHandler` implementation that converts `HttpResponse` messages to `Content` instances.
  Since:
    4.4
  See Also:
    `Content`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ContentResponseHandler()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Content` | `handleEntity(HttpEntity entity)` Handle the response entity and transform it into the actual response object.
    `Content` | `handleResponse(ClassicHttpResponse response)` Handles a successful response (2xx status code) and returns the response entity as a `Content` object.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ContentResponseHandler

          public ContentResponseHandler()

  - ### Method Detail

    - #### handleEntity

          public Content handleEntity(HttpEntity entity)
                               throws IOException

      Description copied from class: `AbstractHttpClientResponseHandler`
      Handle the response entity and transform it into the actual response object.
      Specified by:
        `handleEntity` in class `AbstractHttpClientResponseHandler<Content>`
      Throws:
        `IOException`

    - #### handleResponse

          public Content handleResponse(ClassicHttpResponse response)
                                 throws IOException

      Handles a successful response (2xx status code) and returns the response entity as a `Content` object. If no response entity exists, `Content.NO_CONTENT` is returned.
      Specified by:
        `handleResponse` in interface `HttpClientResponseHandler<Content>`
      Overrides:
        `handleResponse` in class `AbstractHttpClientResponseHandler<Content>`
      Parameters:
        `response` - the HTTP response.
      Returns:
        a `Content` object that encapsulates the response body, or `Content.NO_CONTENT` if the response body is `null` or has zero length.
      Throws:
        `HttpResponseException` - if the response was unsuccessful (status code greater than 300).
        `IOException` - if an I/O error occurs.

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.