@Immutable public class BasicResponseHandler extends AbstractResponseHandler<java.lang.String>
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.http.client.methods.HttpUriRequest, org.apache.http.client.ResponseHandler)
,
HttpClient may handle redirects (3xx responses) internally.
Constructor and Description |
---|
BasicResponseHandler() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
handleEntity(HttpEntity entity)
Returns the entity as a body as a String.
|
java.lang.String |
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).
|
public java.lang.String handleEntity(HttpEntity entity) throws java.io.IOException
handleEntity
in class AbstractResponseHandler<java.lang.String>
java.io.IOException
public java.lang.String handleResponse(HttpResponse response) throws HttpResponseException, java.io.IOException
AbstractResponseHandler
HttpResponseException
.handleResponse
in interface ResponseHandler<java.lang.String>
handleResponse
in class AbstractResponseHandler<java.lang.String>
response
- The response to processClientProtocolException
- in case of an http protocol errorjava.io.IOException
- in case of a problem or the connection was abortedHttpResponseException