Class CommonsHttpClientResponseHandler

java.lang.Object
eu.europa.esig.dss.service.http.commons.CommonsHttpClientResponseHandler
All Implemented Interfaces:
org.apache.hc.core5.http.io.HttpClientResponseHandler<byte[]>

public class CommonsHttpClientResponseHandler extends Object implements org.apache.hc.core5.http.io.HttpClientResponseHandler<byte[]>
This is a default implementation of HttpClientResponseHandler<byte[]> to be used within eu.europa.esig.dss.service.http.commons.CommonsDataLoader. This class is used to read the org.apache.hc.core5.http.ClassicHttpResponse and return a byte[] representing the obtained data in case of success.
  • Constructor Details

    • CommonsHttpClientResponseHandler

      public CommonsHttpClientResponseHandler()
      Default constructor to instantiate the CommonsHttpClientResponseHandler
  • Method Details

    • getAcceptedHttpStatuses

      public List<Integer> getAcceptedHttpStatuses()
      Returns a list of accepted HTTP status numbers
      Returns:
      a list of accepted HTTP status numbers
    • setAcceptedHttpStatuses

      public void setAcceptedHttpStatuses(List<Integer> acceptedHttpStatuses)
      This allows to set a list of accepted http status. Example: 200 (OK)
      Parameters:
      acceptedHttpStatuses - a list of integer which correspond to the http status code
    • handleResponse

      public byte[] handleResponse(org.apache.hc.core5.http.ClassicHttpResponse classicHttpResponse) throws IOException
      Specified by:
      handleResponse in interface org.apache.hc.core5.http.io.HttpClientResponseHandler<byte[]>
      Throws:
      IOException
    • getContent

      protected byte[] getContent(org.apache.hc.core5.http.HttpEntity responseEntity) throws IOException
      Gets content of the response
      Parameters:
      responseEntity - HttpEntity
      Returns:
      byte array
      Throws:
      IOException - if an exception occurs
    • closeQuietly

      protected void closeQuietly(org.apache.hc.core5.http.ClassicHttpResponse classicHttpResponse)
      This method closes the ClassicHttpResponse
      Parameters:
      classicHttpResponse - ClassicHttpResponse to close