@Contract(threading=STATELESS) public class BasicHttpClientResponseHandler extends AbstractHttpClientResponseHandler<String>
HttpClientResponseHandler
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.hc.core5.http.ClassicHttpRequest,
org.apache.hc.core5.http.io.HttpClientResponseHandler)
,
HttpClient may handle redirects (3xx responses) internally.
Constructor and Description |
---|
BasicHttpClientResponseHandler() |
Modifier and Type | Method and Description |
---|---|
String |
handleEntity(HttpEntity entity)
Returns the entity as a body as a String.
|
String |
handleResponse(ClassicHttpResponse 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(HttpEntity entity) throws IOException
handleEntity
in class AbstractHttpClientResponseHandler<String>
IOException
public String handleResponse(ClassicHttpResponse response) throws IOException
AbstractHttpClientResponseHandler
HttpResponseException
.handleResponse
in interface HttpClientResponseHandler<String>
handleResponse
in class AbstractHttpClientResponseHandler<String>
response
- The response to processIOException
- in case of a problem or the connection was aborted