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 Summary
ConstructorDescriptionDefault constructor to instantiate theCommonsHttpClientResponseHandler
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
closeQuietly
(org.apache.hc.core5.http.ClassicHttpResponse classicHttpResponse) This method closes theClassicHttpResponse
Returns a list of accepted HTTP status numbersprotected byte[]
getContent
(org.apache.hc.core5.http.HttpEntity responseEntity) Gets content of the responsebyte[]
handleResponse
(org.apache.hc.core5.http.ClassicHttpResponse classicHttpResponse) void
setAcceptedHttpStatuses
(List<Integer> acceptedHttpStatuses) This allows to set a list of accepted http status.
-
Constructor Details
-
CommonsHttpClientResponseHandler
public CommonsHttpClientResponseHandler()Default constructor to instantiate theCommonsHttpClientResponseHandler
-
-
Method Details
-
getAcceptedHttpStatuses
Returns a list of accepted HTTP status numbers- Returns:
- a list of accepted HTTP status numbers
-
setAcceptedHttpStatuses
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 interfaceorg.apache.hc.core5.http.io.HttpClientResponseHandler<byte[]>
- Throws:
IOException
-
getContent
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 theClassicHttpResponse
- Parameters:
classicHttpResponse
-ClassicHttpResponse
to close
-