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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract T
    handleEntity(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).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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. Never null.
      Returns:
      the result. May be null.
      Throws:
      IOException - on IO error
      SMPClientBadResponseException - 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 an HttpResponseException.
      Specified by:
      handleResponse in interface org.apache.hc.core5.http.io.HttpClientResponseHandler<T>
      Throws:
      IOException