@Contract(threading=IMMUTABLE) public class BasicResponseHandler extends AbstractResponseHandler<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 |
---|---|
String |
handleEntity(org.apache.http.HttpEntity entity)
Returns the entity as a body as a String.
|
String |
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).
|
public String handleEntity(org.apache.http.HttpEntity entity) throws IOException
handleEntity
in class AbstractResponseHandler<String>
IOException
public String handleResponse(org.apache.http.HttpResponse response) throws HttpResponseException, IOException
AbstractResponseHandler
HttpResponseException
.handleResponse
in interface ResponseHandler<String>
handleResponse
in class AbstractResponseHandler<String>
response
- The response to processClientProtocolException
- in case of an http protocol errorIOException
- in case of a problem or the connection was abortedHttpResponseException
Copyright © 1999–2022 The Apache Software Foundation. All rights reserved.