Class BasicHttpClientResponseHandler
- java.lang.Object
-
- org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler<java.lang.String>
-
- org.apache.hc.client5.http.impl.classic.BasicHttpClientResponseHandler
-
- All Implemented Interfaces:
org.apache.hc.core5.http.io.HttpClientResponseHandler<java.lang.String>
@Contract(threading=STATELESS) public class BasicHttpClientResponseHandler extends AbstractHttpClientResponseHandler<java.lang.String>
AHttpClientResponseHandler
that returns the response body as a String for successful (2xx) responses. If the response code was >= 300, the response body is consumed and anHttpResponseException
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.- Since:
- 4.0
-
-
Constructor Summary
Constructors Constructor Description BasicHttpClientResponseHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
handleEntity(org.apache.hc.core5.http.HttpEntity entity)
Returns the entity as a body as a String.java.lang.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).
-
-
-
Method Detail
-
handleEntity
public java.lang.String handleEntity(org.apache.hc.core5.http.HttpEntity entity) throws java.io.IOException
Returns the entity as a body as a String.- Specified by:
handleEntity
in classAbstractHttpClientResponseHandler<java.lang.String>
- Throws:
java.io.IOException
-
handleResponse
public java.lang.String handleResponse(org.apache.hc.core5.http.ClassicHttpResponse response) throws java.io.IOException
Description copied from class:AbstractHttpClientResponseHandler
Read the entity from the response body and pass it to the entity handler method 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:
handleResponse
in interfaceorg.apache.hc.core5.http.io.HttpClientResponseHandler<java.lang.String>
- Overrides:
handleResponse
in classAbstractHttpClientResponseHandler<java.lang.String>
- Throws:
java.io.IOException
-
-