Top Description Constructors Methods
org.apache.hc.client5.http.impl.classic

public Class BasicHttpClientResponseHandler

extends AbstractHttpClientResponseHandler<String>
Class Inheritance
Annotations
@Contract
threading:STATELESS
Imports
java.io.IOException, org.apache.hc.client5.http.ClientProtocolException, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.ClassicHttpResponse, .HttpEntity, .ParseException, org.apache.hc.core5.http.io.entity.EntityUtils

A org.apache.hc.core5.http.io.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 org.apache.hc.client5.http.HttpResponseException is thrown.

If this is used with org.apache.hc.client5.http.classic.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

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
handleEntity(final HttpEntity entity)

Implements abstract org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler.handleEntity.

Returns the entity as a body as a String.
public String
handleResponse(final ClassicHttpResponse
The response to process
response
)

Overrides org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler.handleResponse.

Implements org.apache.hc.core5.http.io.HttpClientResponseHandler.handleResponse.

Read the entity from the response body and pass it to the entity handler method if the response was successful (a 2xx status code).

Constructor Detail

BasicHttpClientResponseHandlerback to summary
public BasicHttpClientResponseHandler()

Method Detail

handleEntityback to summary
public String handleEntity(final HttpEntity entity) throws IOException

Implements abstract org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler.handleEntity.

Returns the entity as a body as a String.

Annotations
@Override
handleResponseback to summary
public String handleResponse(final ClassicHttpResponse response) throws IOException

Overrides org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler.handleResponse.

Implements org.apache.hc.core5.http.io.HttpClientResponseHandler.handleResponse.

Doc from org.apache.hc.client5.http.impl.classic.AbstractHttpClientResponseHandler.handleResponse.

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 an HttpResponseException.

Parameters
response:ClassicHttpResponse

Doc from org.apache.hc.core5.http.io.HttpClientResponseHandler.handleResponse.

The response to process

Returns:String

Doc from org.apache.hc.core5.http.io.HttpClientResponseHandler.handleResponse.

A value determined by the response

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.hc.core5.http.io.HttpClientResponseHandler.handleResponse.

in case of a problem or the connection was aborted