Package 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
,ContentResponseHandler
@Contract(threading=IMMUTABLE) public abstract class AbstractResponseHandler<T> extends java.lang.Object implements ResponseHandler<T>
A genericResponseHandler
that works with the response entity for successful (2xx) responses. If the response code was >= 300, the response body is consumed and anHttpResponseException
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
Constructors Constructor Description AbstractResponseHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract T
handleEntity(HttpEntity entity)
Handle the response entity and transform it into the actual response object.T
handleResponse(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).
-
-
-
Method Detail
-
handleResponse
public T handleResponse(HttpResponse response) throws HttpResponseException, java.io.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 anHttpResponseException
.- Specified by:
handleResponse
in interfaceResponseHandler<T>
- Parameters:
response
- The response to process- Returns:
- A value determined by the response
- Throws:
ClientProtocolException
- in case of an http protocol errorjava.io.IOException
- in case of a problem or the connection was abortedHttpResponseException
-
handleEntity
public abstract T handleEntity(HttpEntity entity) throws java.io.IOException
Handle the response entity and transform it into the actual response object.- Throws:
java.io.IOException
-
-