Package com.helger.smpclient.httpclient
Class AbstractSMPResponseHandler<T>
java.lang.Object
com.helger.smpclient.httpclient.AbstractSMPResponseHandler<T>
- Type Parameters:
T- Date type to be created
- All Implemented Interfaces:
org.apache.hc.core5.http.io.HttpClientResponseHandler<T>
- Direct Known Subclasses:
SMPHttpResponseHandlerSigned,SMPHttpResponseHandlerUnsigned,SMPHttpResponseHandlerWriteOperations
public abstract class AbstractSMPResponseHandler<T>
extends Object
implements org.apache.hc.core5.http.io.HttpClientResponseHandler<T>
Abstract
HttpClientResponseHandler implementation that ensures a leak
free usage of the returned response.
Note: this class is also licensed under Apache 2 license, as it was not part of the original implementation
- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ThandleEntity(org.apache.hc.core5.http.HttpEntity aEntity) Handle the response entity and transform it into the actual response object.handleResponse(org.apache.hc.core5.http.ClassicHttpResponse aResponse) 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 Details
-
AbstractSMPResponseHandler
public AbstractSMPResponseHandler()
-
-
Method Details
-
handleEntity
@Nullable public abstract T handleEntity(@Nonnull org.apache.hc.core5.http.HttpEntity aEntity) throws IOException, SMPClientBadResponseException Handle the response entity and transform it into the actual response object.- Parameters:
aEntity- The entity to handle. Nevernull.- Returns:
- the result. May be
null. - Throws:
IOException- on IO errorSMPClientBadResponseException- if something goes wrong
-
handleResponse
@Nullable public T handleResponse(@Nonnull org.apache.hc.core5.http.ClassicHttpResponse aResponse) throws IOException 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:
handleResponsein interfaceorg.apache.hc.core5.http.io.HttpClientResponseHandler<T>- Throws:
IOException
-