Class NativeHTTPDataLoader
java.lang.Object
eu.europa.esig.dss.spi.client.http.NativeHTTPDataLoader
- All Implemented Interfaces:
DataLoader
,Serializable
Implementation of native java DataLoader using the java.net.URL class.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static enum
Available HTTPMethodsNested classes/interfaces inherited from interface eu.europa.esig.dss.spi.client.http.DataLoader
DataLoader.DataAndUrl
-
Constructor Summary
ConstructorDescriptionDefault constructor instantiating object with null values -
Method Summary
Modifier and TypeMethodDescriptionprotected Callable
<byte[]> createNativeDataLoaderCall
(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh) 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 cacherefresh
when definedExecute a HTTP GET operation.int
Gets the timeout value on connection establishment with a remote resourceint
Gets the maximum InputStream sizeint
Gets 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) Execute the requestvoid
setConnectTimeout
(int connectTimeout) Sets the timeout to establish a connection with a remote resource (in milliseconds).void
setContentType
(String contentType) This allows to set the content type.void
setMaxInputSize
(int maxInputSize) Sets the maximum InputStream sizevoid
setReadTimeout
(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:DataLoader
This allows to set the content type. Example: Content-Type "application/ocsp-request"- Specified by:
setContentType
in 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
protected byte[] request(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh) Execute the request- Parameters:
url
-String
method
-NativeHTTPDataLoader.HttpMethod
content
- request contentrefresh
- if enforce the refresh- Returns:
- response binaries
-
createNativeDataLoaderCall
protected Callable<byte[]> createNativeDataLoaderCall(String url, NativeHTTPDataLoader.HttpMethod method, byte[] content, boolean refresh) This method creates a task call to be executed by NativeHTTPDataLoader- Parameters:
url
-String
URL to callmethod
-NativeHTTPDataLoader.HttpMethod
of the requestcontent
- byte array containing a body of the request, when requiredrefresh
- defined if the cache should be used- Returns:
Callable
task
-
get
Description copied from interface:DataLoader
Execute 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:
get
in interfaceDataLoader
- Parameters:
urlStrings
-List
ofString
s representing the URLs to be used in sequential way to obtain the data.- Returns:
DataAndUrl
representing the array of obtained data and used url, or null
-
get
Description copied from interface:DataLoader
Execute a HTTP GET operation.- Specified by:
get
in interfaceDataLoader
- Parameters:
url
- the url to access- Returns:
byte
array of obtained data or null
-
get
Executes a GET request to the provided URL, with a forced cacherefresh
when 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:DataLoader
Executes a HTTP POST operation- Specified by:
post
in interfaceDataLoader
- Parameters:
url
- to accesscontent
- the content to post- Returns:
byte
array of obtained data
-