Package org.apache.http.impl.client
Class BasicResponseHandler
java.lang.Object
org.apache.http.impl.client.BasicResponseHandler
- All Implemented Interfaces:
ResponseHandler<String>
public class BasicResponseHandler extends Object implements ResponseHandler<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
{@link org.apache.http.client.HttpClient#execute(
org.apache.http.client.methods.HttpUriRequest, ResponseHandler),
HttpClient may handle redirects (3xx responses) internally.- Since:
- 4.0
- Version:
- $Revision: 677240 $
- Author:
- Oleg Kalnichevski
-
Constructor Summary
Constructors Constructor Description BasicResponseHandler() -
Method Summary
Modifier and Type Method Description StringhandleResponse(HttpResponse response)Returns the response body as a String if the response was successful (a 2xx status code).
-
Constructor Details
-
BasicResponseHandler
public BasicResponseHandler()
-
-
Method Details
-
handleResponse
Returns the response body as a String 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:
handleResponsein interfaceResponseHandler<String>- Parameters:
response- The response to process- Returns:
- A value determined by the response
- Throws:
ClientProtocolException- in case of an http protocol errorIOException- in case of a problem or the connection was abortedHttpResponseException
-