org.apache.hc.client5.http.impl

## Class BasicResponseHandler

- java.lang.Object
- - org.apache.hc.client5.http.impl.sync.AbstractResponseHandler<String>
  - - org.apache.hc.client5.http.impl.BasicResponseHandler

All Implemented Interfaces:
  ResponseHandler<String>

    @Immutable
    public class BasicResponseHandler
    extends AbstractResponseHandler<String>

A `ResponseHandler` that returns the response body as a String for successful (2xx) responses. If the response code was >= 300, the response body is consumed and an `HttpResponseException` is thrown.

If this is used with `HttpClient.execute( org.apache.hc.client5.http.methods.HttpUriRequest, org.apache.hc.client5.http.sync.ResponseHandler)`, HttpClient may handle redirects (3xx responses) internally.

Since:
  4.0

### Constructor Summary

Constructors
Constructor and Description
`BasicResponseHandler()`

### Method Summary

Methods
`String` `handleEntity(org.apache.hc.core5.http.HttpEntity entity)` Returns the entity as a body as a String.
`String` `handleResponse(org.apache.hc.core5.http.HttpResponse response)` Read the entity from the response body and pass it to the entity handler method if the response was successful (a 2xx status code).

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

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

### Constructor Detail

#### BasicResponseHandler

    public BasicResponseHandler()

### Method Detail

#### handleEntity

    public String handleEntity(org.apache.hc.core5.http.HttpEntity entity)
                        throws IOException

Returns the entity as a body as a String.

Specified by:
  `handleEntity` in class `AbstractResponseHandler<String>`
Throws:
  `IOException`

#### handleResponse

    public String handleResponse(org.apache.hc.core5.http.HttpResponse response)
                          throws IOException

Description copied from class: `AbstractResponseHandler`
Read the entity from the response body and pass it to the entity handler method if the response was successful (a 2xx status code). If no response body exists, this returns null. If the response was unsuccessful (>= 300 status code), throws an `HttpResponseException`.

Specified by:
  `handleResponse` in interface `ResponseHandler<String>`
Overrides:
  `handleResponse` in class `AbstractResponseHandler<String>`
Parameters:
  `response` - The response to process
Returns:
  A value determined by the response
Throws:
  `IOException` - in case of a problem or the connection was aborted