AbstractResponseHandler (Apache HttpClient 4.5.13 API)
Date: 2020-10-03

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.http.impl.client
Class AbstractResponseHandler<T>

    java.lang.Object
      org.apache.http.impl.client.AbstractResponseHandler<T>

All Implemented Interfaces:
  ResponseHandler<T>

Direct Known Subclasses:
  BasicResponseHandler

    @Contract(threading=IMMUTABLE)
    public abstract class AbstractResponseHandler<T>

extends Object
implements ResponseHandler<T>

A generic `ResponseHandler` that works with the response entity 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.http.client.methods.HttpUriRequest, ResponseHandler)`, HttpClient may handle redirects (3xx responses) internally.

Since:
  4.4

Constructor Summary
`AbstractResponseHandler()`

Method Summary
`abstract T` | `handleEntity(org.apache.http.HttpEntity entity)` Handle the response entity and transform it into the actual response object.
`T` | `handleResponse(org.apache.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

### AbstractResponseHandler

    public AbstractResponseHandler()

Method Detail

### handleResponse

    public T handleResponse(org.apache.http.HttpResponse response)
                     throws HttpResponseException,
                            IOException

  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<T>`
  Parameters:
    `response` - The response to process
  Returns:
    A value determined by the response
  Throws:
    `ClientProtocolException` - in case of an http protocol error
    `IOException` - in case of a problem or the connection was aborted
    `HttpResponseException`

### handleEntity

    public abstract T handleEntity(org.apache.http.HttpEntity entity)
                            throws IOException

  Handle the response entity and transform it into the actual response object.

  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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