@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(org.apache.hc.core5.http.HttpEntity entity)
Returns the entity as a body as a String.
|
String |
handleResponse(org.apache.hc.core5.http.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(org.apache.hc.core5.http.HttpEntity entity) throws IOException
handleEntity
in class AbstractHttpClientResponseHandler<String>
IOException
public String handleResponse(org.apache.hc.core5.http.ClassicHttpResponse response) throws IOException
AbstractHttpClientResponseHandler
HttpResponseException
.handleResponse
in interface org.apache.hc.core5.http.io.HttpClientResponseHandler<String>
handleResponse
in class AbstractHttpClientResponseHandler<String>
IOException
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.