Class NativeHTTPDataLoader
java.lang.Object
eu.europa.esig.dss.spi.client.http.NativeHTTPDataLoader
- All Implemented Interfaces:
AdvancedDataLoader, DataLoader, Serializable
Implementation of native java DataLoader using the java.net.URL class.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumAvailable HTTPMethodsNested classes/interfaces inherited from interface DataLoader
DataLoader.DataAndUrl -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor instantiating object with null values -
Method Summary
Modifier and TypeMethodDescriptionprotected Callable<byte[]> createNativeDataLoaderCall(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh) Deprecated.since DSS 6.4.protected Callable<ResponseEnvelope> createNativeHTTPDataLoaderCall(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh, boolean includeResponseDetails, boolean includeResponseBody) This method creates a task call to be executed by NativeHTTPDataLoaderbyte[]Execute a HTTP GET operation.byte[]Executes a GET request to the provided URL, with a forced cacherefreshwhen definedExecute a HTTP GET operation.intGets the timeout value on connection establishment with a remote resourceintGets the maximum InputStream sizeintGets the timeout value on response reading from a remote resourcebyte[]Executes a HTTP POST operationprotected byte[]request(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh) Deprecated.since DSS 6.4.protected ResponseEnveloperequest(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh, boolean includeResponseDetails, boolean includeResponseBody) Execute the requestrequestGet(String url) Executes a GET request and returns anResponseEnvelopeobject.requestGet(String url, boolean includeResponseDetails) Executes a GET request and returns anResponseEnvelopeobject.requestGet(String url, boolean includeResponseDetails, boolean includeResponseBody) Executes a GET request and returns anResponseEnvelopeobject.requestPost(String url, byte[] content) Executes a POST request and returns anResponseEnvelopeobject.requestPost(String url, byte[] content, boolean includeResponseDetails) Executes a POST request and returns anResponseEnvelopeobject.requestPost(String url, byte[] content, boolean includeResponseDetails, boolean includeResponseBody) Executes a POST request and returns anResponseEnvelopeobject.voidsetConnectTimeout(int connectTimeout) Sets the timeout to establish a connection with a remote resource (in milliseconds).voidsetContentType(String contentType) This allows to set the content type.voidsetMaxInputSize(int maxInputSize) Sets the maximum InputStream sizevoidsetReadTimeout(int readTimeout) Sets the timeout to read a response from a remote resource (in milliseconds).
-
Constructor Details
-
NativeHTTPDataLoader
public NativeHTTPDataLoader()Default constructor instantiating object with null values
-
-
Method Details
-
setContentType
Description copied from interface:DataLoaderThis allows to set the content type. Example: Content-Type "application/ocsp-request"- Specified by:
setContentTypein interfaceDataLoader- Parameters:
contentType- to set the Content-Type
-
getMaxInputSize
public int getMaxInputSize()Gets the maximum InputStream size- Returns:
- maximum InputStream size
-
setMaxInputSize
public void setMaxInputSize(int maxInputSize) Sets the maximum InputStream size- Parameters:
maxInputSize- maximum InputStream size
-
getConnectTimeout
public int getConnectTimeout()Gets the timeout value on connection establishment with a remote resource- Returns:
- connection timeout value
-
setConnectTimeout
public void setConnectTimeout(int connectTimeout) Sets the timeout to establish a connection with a remote resource (in milliseconds). Zero (0) value is used for no timeout. Default: 0 (no timeout)- Parameters:
connectTimeout- connection timeout value (in milliseconds)
-
getReadTimeout
public int getReadTimeout()Gets the timeout value on response reading from a remote resource- Returns:
- read timeout value
-
setReadTimeout
public void setReadTimeout(int readTimeout) Sets the timeout to read a response from a remote resource (in milliseconds). Zero (0) value is used for no timeout. Default: 0 (no timeout)- Parameters:
readTimeout- read timeout value (in milliseconds)
-
request
@Deprecated protected byte[] request(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh) Deprecated.since DSS 6.4. Please use#request(url, method, content, refresh, true, false)method instead.Execute the request- Parameters:
url-Stringmethod-NativeHTTPDataLoader.HttpMethodcontent- request contentrefresh- if enforce the refresh- Returns:
- response binaries
-
createNativeHTTPDataLoaderCall
protected Callable<ResponseEnvelope> createNativeHTTPDataLoaderCall(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh, boolean includeResponseDetails, boolean includeResponseBody) This method creates a task call to be executed by NativeHTTPDataLoader- Parameters:
url-StringURL to callmethod-NativeHTTPDataLoader.HttpMethodof the requestcontent- byte array containing a body of the request, when requiredrefresh- defined if the cache should be usedincludeResponseDetails- whether HTTP content information is to be included in the response objectincludeResponseBody- whether the response message body is to be included in the output response object- Returns:
Callabletask
-
request
protected ResponseEnvelope request(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh, boolean includeResponseDetails, boolean includeResponseBody) Execute the request- Parameters:
url-Stringmethod-NativeHTTPDataLoader.HttpMethodcontent- request contentrefresh- if enforce the refreshincludeResponseDetails- whether HTTP content information is to be included in the response objectincludeResponseBody- whether the response message body is to be included in the output response object- Returns:
- response binaries
-
createNativeDataLoaderCall
@Deprecated protected Callable<byte[]> createNativeDataLoaderCall(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh) Deprecated.since DSS 6.4. Please use#createNativeHTTPDataLoaderCall( String url, HttpMethod method, byte[] content, boolean refresh, boolean includeHTTPContent)method insteadThis method creates a task call to be executed by NativeHTTPDataLoader- Parameters:
url-StringURL to callmethod-NativeHTTPDataLoader.HttpMethodof the requestcontent- byte array containing a body of the request, when requiredrefresh- defined if the cache should be used- Returns:
Callabletask
-
get
Description copied from interface:DataLoaderExecute a HTTP GET operation. This method is used when many URls are available to access the same resource. The operation stops after the first successful download.- Specified by:
getin interfaceDataLoader- Parameters:
urlStrings-ListofStrings representing the URLs to be used in sequential way to obtain the data.- Returns:
DataAndUrlrepresenting the array of obtained data and used url, or null
-
get
Description copied from interface:DataLoaderExecute a HTTP GET operation.- Specified by:
getin interfaceDataLoader- Parameters:
url- the url to access- Returns:
bytearray of obtained data or null
-
get
Executes a GET request to the provided URL, with a forced cacherefreshwhen defined- Parameters:
url- to accessrefresh- if true indicates that the data should be refreshed- Returns:
- binaries of the extracted data object
-
post
Description copied from interface:DataLoaderExecutes a HTTP POST operation- Specified by:
postin interfaceDataLoader- Parameters:
url- to accesscontent- the content to post- Returns:
bytearray of obtained data
-
requestGet
Description copied from interface:AdvancedDataLoaderExecutes a GET request and returns anResponseEnvelopeobject. This method included the response message body, context and metadata within the response object.- Specified by:
requestGetin interfaceAdvancedDataLoader- Parameters:
url-StringURL to perform request to- Returns:
ResponseEnvelope
-
requestGet
Description copied from interface:AdvancedDataLoaderExecutes a GET request and returns anResponseEnvelopeobject. This method allows configuration whether the response context (HTTP headers, TLS/SSL certificates, etc.), is to be included within the response object. The response body will be included within the response, when calling this method.- Specified by:
requestGetin interfaceAdvancedDataLoader- Parameters:
url-StringURL to perform request toincludeResponseDetails- defines whether the response context (HTTP headers, metadata) is to be included within the response- Returns:
ResponseEnvelope
-
requestGet
public ResponseEnvelope requestGet(String url, boolean includeResponseDetails, boolean includeResponseBody) Description copied from interface:AdvancedDataLoaderExecutes a GET request and returns anResponseEnvelopeobject. This method allows configuration whether the response context (HTTP headers, TLS/SSL certificates, etc.), as well as the response message body are to be included within the response object. The data which is not included, won't be read by the execution process, thus helping to achieve time-memory efficiency.- Specified by:
requestGetin interfaceAdvancedDataLoader- Parameters:
url-StringURL to perform request toincludeResponseDetails- defines whether the response context (HTTP headers, metadata) is to be included within the responseincludeResponseBody- defines whether the response body is to be included within the response- Returns:
ResponseEnvelope
-
requestPost
Description copied from interface:AdvancedDataLoaderExecutes a POST request and returns anResponseEnvelopeobject. This method included the response message body, context and metadata within the response object.- Specified by:
requestPostin interfaceAdvancedDataLoader- Parameters:
url-StringURL to perform request tocontent- byte array containing request content for the POST call- Returns:
ResponseEnvelope
-
requestPost
Description copied from interface:AdvancedDataLoaderExecutes a POST request and returns anResponseEnvelopeobject. This method allows configuration whether the response context (HTTP headers, TLS/SSL certificates, etc.), is to be included within the response object. The response body will be included within the response, when calling this method.- Specified by:
requestPostin interfaceAdvancedDataLoader- Parameters:
url-StringURL to perform request tocontent- byte array containing request content for the POST callincludeResponseDetails- defines whether the response context (HTTP headers, metadata) is to be included within the response- Returns:
ResponseEnvelope
-
requestPost
public ResponseEnvelope requestPost(String url, byte[] content, boolean includeResponseDetails, boolean includeResponseBody) Description copied from interface:AdvancedDataLoaderExecutes a POST request and returns anResponseEnvelopeobject. This method allows configuration whether the response context (HTTP headers, TLS/SSL certificates, etc.), as well as the response message body are to be included within the response object. The data which is not included, won't be read by the execution process, thus helping to achieve time-memory efficiency.- Specified by:
requestPostin interfaceAdvancedDataLoader- Parameters:
url-StringURL to perform request tocontent- byte array containing request content for the POST callincludeResponseDetails- defines whether the response context (HTTP headers, metadata) is to be included within the responseincludeResponseBody- defines whether the response body is to be included within the response- Returns:
ResponseEnvelope
-