Package com.logicaldoc.core.automation
Class HttpTool
java.lang.Object
com.logicaldoc.core.automation.HttpTool
Utility methods to call URLs
- Since:
- 9.2
- Author:
- Marco Meschieri - LogicalDOC
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDownloads a file from a URLdownload
(String url, Map<String, String> headers, Map<String, org.apache.hc.client5.http.entity.mime.AbstractContentBody> parts, int timeout) Downloads a file received in answer to a multipart POST requestCalls the provided URL with an HTTP GET requestCalls the provided URL with an HTTP POST requestSends a HTTP POST request containing a urlencoded formpostMultipart
(String url, Map<String, String> headers, Map<String, org.apache.hc.client5.http.entity.mime.AbstractContentBody> parts, int timeout) Sends a HTTP POST with multiple parts
-
Constructor Details
-
HttpTool
public HttpTool()
-
-
Method Details
-
get
Calls the provided URL with an HTTP GET request- Parameters:
url
- The URL to callheaders
- Optional map of headerstimeout
- Timeout in seconds- Returns:
- The response body
-
download
Downloads a file from a URL- Parameters:
url
- The URL to callheaders
- Optional map of headerstimeout
- Timeout in seconds- Returns:
- The downloaded file, this is a temporary file, remember to delete it when done
-
post
Calls the provided URL with an HTTP POST request- Parameters:
url
- The URL to callheaders
- Optional map of headersentity
- Body of the POST requesttimeout
- Timeout in seconds- Returns:
- The response body
-
postForm
public String postForm(String url, Map<String, String> headers, Map<String, String> fields, int timeout) Sends a HTTP POST request containing a urlencoded form- Parameters:
url
- The URL to callheaders
- Optional map of headersfields
- The fields of the formtimeout
- Timeout in seconds- Returns:
- The response body
-
postMultipart
public String postMultipart(String url, Map<String, String> headers, Map<String, org.apache.hc.client5.http.entity.mime.AbstractContentBody> parts, int timeout) Sends a HTTP POST with multiple parts- Parameters:
url
- The URL to callheaders
- Optional map of headersparts
- Map of the partstimeout
- Timeout in seconds- Returns:
- The response body
-
download
public File download(String url, Map<String, String> headers, Map<String, org.apache.hc.client5.http.entity.mime.AbstractContentBody> parts, int timeout) Downloads a file received in answer to a multipart POST request- Parameters:
url
- The URL to callheaders
- Optional map of headersparts
- Map of the partstimeout
- Timeout in seconds- Returns:
- The downloaded file, this is a temporary file, remember to delete it when done
-