# Actions: Net

install4j BeanInfo catalog. Each entry below documents a bean class that can appear inside a `<serializedBean>` element in an install4j project file.

## Contents

- [Download file](#download-file) — `com.install4j.runtime.beans.actions.net.DownloadFileAction`
- [HTTP request](#http-request) — `com.install4j.runtime.beans.actions.net.HttpRequestAction`
- [Upload file](#upload-file) — `com.install4j.runtime.beans.actions.net.UploadFileAction`
- [Wait for HTTP server](#wait-for-http-server) — `com.install4j.runtime.beans.actions.net.WaitForHttpServerAction`
- [Wait for Socket](#wait-for-socket) — `com.install4j.runtime.beans.actions.net.WaitForSocketAction`

---

### Download file
- **Class:** `com.install4j.runtime.beans.actions.net.DownloadFileAction`
- **Category:** HTTP and network
- **Multiple instances:** yes

Download a URL and save it to a file

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `connectionFailureScript` — Network failure script | ScriptProperty → ErrorHandlingMode | Error Handling | — | A script that is executed if the HTTP connection fails in such a way, that the proxy dialog would have to be shown. If you return ErrorHandlingMode.IGNORE, the regular proxy or failure handling will proceed, if you return ErrorHandlingMode.CANCEL, the action will fail immediately. If you can take corrective action in the script, you can return ErrorHandlingMode.RETRY to make the same HTTP request again. However, you have to take special care not to enter an infinite loop. Typically, there should be user input before you retry and the user should be given the option to cancel.The script is only executed for actual network failures, and not if the server or the proxy connection requires authentication. |
| `acceptAllCertificates` — Accept all SSL certificates | boolean | Error Handling | — | If the protocol of the URL starts with "https" and this property is selected, the SSL certificate will not be checked for validity. This is only recommended for testing purposes when working with self-signed certificates. |
| `connectTimeout` — Connect timeout in ms | int | Error Handling | — | The timeout for establishing the socket connection in milliseconds. A timeout of zero is interpreted as an infinite timeout. |
| `readTimeout` — Read timeout in ms | int | Error Handling | — | The timeout for reading data from the socket connection in milliseconds. A timeout of zero is interpreted as an infinite timeout. |
| `url` — URL | String | Configuration | — | The URL from which the file should be downloaded. The URL must start with http:// or https://. If you add a query string, it must already be URL encoded. |
| `targetFile` — Target file | File | Configuration | — | The file to which the downloaded URL will be saved. |
| `requestHeaders` — Request headers | List [context=requestHeaders] | Configuration | — | A list of name-value pairs that should be set as additional headers for the request. Request headers that are installer variables with array or collection values (e.g. String[], Object[] or List<File>) are expanded as separate request headers, this allows you to build a variable length list of request headers at runtime. |
| `logRequestHeaders` — Log request headers | boolean | Configuration | — | If the request headers should be written into the log file or not. Disabled by default due to security reasons. |
| `showError` — Show error message | boolean | Error Handling | — | Show a default error message if the download fails. |
| `retryIfInterrupted` — Retry if interrupted | boolean | Configuration | — | If selected, ask the user to retry if a successfully started download is interrupted. |
| `checkDigest` — Check digest | boolean | Configuration | — | If selected, the action will try to download a file named sha256sums or md5sums from either the directory of the above URL or from the optional URL given below. If the download is successful and the file contains an entry for the target file name, it will be checked. If the checksums do not match and the "Silent failure" option is not selected, a dialog will be shown that offers the possibility to retry the download. |
| `digestAlgorithm` — Digest algorithm | [DigestAlgorithm](enums.md#digestalgorithm) | Configuration | `checkDigest`=true | The digest algorithm to use. This also determines the file name for the digest URL. |
| `digestUrl` — Optional digest file URL | String | Configuration | `checkDigest`=true | An optional URL for the digest file. If specified, only this URL will be used. |
| `dontAskForRetry` — Silent failure | boolean | Configuration | `checkDigest`=true | If selected, the action will fail immediately if a mismatch in the checksums occurs. Otherwise, the user will be presented with a dialog box that explains the failure and offers the possibility to retry the download. |
| `showProgress` — Show progress | boolean | Configuration | — | If selected, and a progress bar is available on the current screen, the action will show its progress in the progress bar. |
| `showFileName` — Show file name | boolean | Configuration | `showProgress`=true | If selected, the name of the downloaded file and the target directory will be displayed. This setting has no effect if "Show progress" is not selected. |
| `deleteOnExit` — Delete downloaded file on exit | boolean | Configuration | — | If selected, the downloaded file will be deleted when the installer application terminates. |

### HTTP request
- **Class:** `com.install4j.runtime.beans.actions.net.HttpRequestAction`
- **Category:** HTTP and network
- **Multiple instances:** yes

Make an HTTP request to a specified URL. All common HTTP request methods are supported for REST calls. For mime types starting with text or containing "charset" information, the response body can be saved to an installer variable. To download large files, use the "Download file" action instead.The action will succeed if an HTTP response code in the 2xx range is received, otherwise it will fail. You can save the response code to a variable to inspect it in a later action.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `connectionFailureScript` — Network failure script | ScriptProperty → ErrorHandlingMode | Error Handling | — | A script that is executed if the HTTP connection fails in such a way, that the proxy dialog would have to be shown. If you return ErrorHandlingMode.IGNORE, the regular proxy or failure handling will proceed, if you return ErrorHandlingMode.CANCEL, the action will fail immediately. If you can take corrective action in the script, you can return ErrorHandlingMode.RETRY to make the same HTTP request again. However, you have to take special care not to enter an infinite loop. Typically, there should be user input before you retry and the user should be given the option to cancel.The script is only executed for actual network failures, and not if the server or the proxy connection requires authentication. |
| `acceptAllCertificates` — Accept all SSL certificates | boolean | Error Handling | — | If the protocol of the URL starts with "https" and this property is selected, the SSL certificate will not be checked for validity. This is only recommended for testing purposes when working with self-signed certificates. |
| `connectTimeout` — Connect timeout in ms | int | Error Handling | — | The timeout for establishing the socket connection in milliseconds. A timeout of zero is interpreted as an infinite timeout. |
| `readTimeout` — Read timeout in ms | int | Error Handling | — | The timeout for reading data from the socket connection in milliseconds. A timeout of zero is interpreted as an infinite timeout. |
| `url` — URL | String | Request | — | The URL for the HTTP request. The URL must start with http:// or https://. If you add a query string, it must already be URL encoded.To post a query string with URL-encoded key-value pairs, use the "Form data" property instead of adding the query string here. |
| `requestMethod` — HTTP request method | [HttpRequestMethod](enums.md#httprequestmethod) | Request | — | The request method for the HTTP protocol can be one of GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE. For POST and PUT, the values entered in the "Form data" property are transmitted in the HTTP message body with the mime type "application/x-www-form-urlencoded". For other request methods, the data is appended as a query string to the URL. |
| `useRequestBody` — Custom request body | boolean | Request | `requestMethod` ∈ [POST, PUT] | If selected, a custom request body is sent. For form data, use the "Form data" property instead. If both form data and a custom request body are present, the form data is appended to the URL. |
| `requestBodyContentType` — Content type | String | Request | `useRequestBody`=true | The content type of the request body. For JSON, use application/json. |
| `requestBody` — Request body | String [context=multiline] | Request | `useRequestBody`=true | The request body as a string. |
| `formData` — Form data | List [context=keyValuePairs] | Request | — | A list of key-value pairs that should be transmitted with this request. Depending on the request method, they are either appended as a query string to the URL or transmitted in the HTTP message body. Key-value pairs that are installer variables with array or collection values (e.g. String[], Object[] or List<File>) are expanded as separate key-value pairs, this allows you to build a variable length list of key-value pairs at runtime. |
| `requestHeaders` — Request headers | List [context=requestHeaders] | Request | — | A list of name-value pairs that should be set as additional headers for the request. Request headers that are installer variables with array or collection values (e.g. String[], Object[] or List<File>) are expanded as separate request headers, this allows you to build a variable length list of request headers at runtime. |
| `logRequestHeaders` — Log request headers | boolean | Request | — | If the request headers should be written into the log file or not. Disabled by default due to security reasons. |
| `performRollbackRequest` — Perform rollback request | boolean | Request | — | If selected, a request is performed in case of a rollback. You can configure the rollback request with the child properties. All other properties, such as error handling are shared with the regular request. |
| `rollbackUrl` — Rollback URL | String | Request | `performRollbackRequest`=true | The URL for the rollback request. The URL must start with http:// or https://. If you add a query string, it must already be URL encoded. |
| `rollbackRequestMethod` — Rollback HTTP request method | [HttpRequestMethod](enums.md#httprequestmethod) | Request | `performRollbackRequest`=true | The request method for the HTTP protocol can be one of GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE. For POST and PUT, the values entered in the "Form data" property are transmitted in the HTTP message body with the mime type "application/x-www-form-urlencoded". For other request methods, the data is appended as a query string to the URL. |
| `useRollbackRequestBody` — Custom request body | boolean | Request | `rollbackRequestMethod` ∈ [POST, PUT] | If selected, a custom request body is sent. For form data, use the "Form data" property instead. If both form data and a custom request body are present, the form data is appended to the URL. |
| `rollbackRequestBodyContentType` — Content type | String | Request | `useRollbackRequestBody`=true | The content type of the request body. For JSON, use application/json. |
| `rollbackRequestBody` — Request body | String [context=multiline] | Request | `useRollbackRequestBody`=true | The request body as a string. |
| `rollbackFormData` — Rollback form data | List [context=keyValuePairs] | Request | `performRollbackRequest`=true | A list of key-value pairs that should be transmitted with this request. Depending on the request method, they are either appended as a query string to the URL or transmitted in the HTTP message body. Key-value pairs that are installer variables with array or collection values (e.g. String[], Object[] or List<File>) are expanded as separate key-value pairs, this allows you to build a variable length list of key-value pairs at runtime. |
| `responseVariableName` — Variable name for response body | String [context=variableName] (variable→ String) | Response | — | Optionally, you can enter a variable name that will be set with the text of the response body as an instance of java.lang.String. The variable value will not be written to the log file.Enter the variable without the installer prefix and the dollar sign.The variable will not be set if the mime type does not start with text/ or contain "charset" information. |
| `responseCodeVariableName` — Variable name for response code | String [context=variableName] (variable→ Integer) | Response | — | Optionally, you can enter a variable name that will be set with the response code as an instance of java.lang.Integer. Enter the variable without the installer prefix and the dollar sign. |
| `responseHeadersVariableName` — Variable name for response headers | String [context=variableName] (variable→ Map) | Response | — | Optionally, you can enter a variable name that will be set with the response headers as an instance of java.util.Map. The keys in the map are the header names, and the values are instances of java.util.List<String> with the header values. The variable value will not be written to the log file.Enter the variable without the installer prefix and the dollar sign. |

### Upload file
- **Class:** `com.install4j.runtime.beans.actions.net.UploadFileAction`
- **Category:** HTTP and network
- **Multiple instances:** yes

Upload a file to an HTTP server with a POST request.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `connectionFailureScript` — Network failure script | ScriptProperty → ErrorHandlingMode | Error Handling | — | A script that is executed if the HTTP connection fails in such a way, that the proxy dialog would have to be shown. If you return ErrorHandlingMode.IGNORE, the regular proxy or failure handling will proceed, if you return ErrorHandlingMode.CANCEL, the action will fail immediately. If you can take corrective action in the script, you can return ErrorHandlingMode.RETRY to make the same HTTP request again. However, you have to take special care not to enter an infinite loop. Typically, there should be user input before you retry and the user should be given the option to cancel.The script is only executed for actual network failures, and not if the server or the proxy connection requires authentication. |
| `acceptAllCertificates` — Accept all SSL certificates | boolean | Error Handling | — | If the protocol of the URL starts with "https" and this property is selected, the SSL certificate will not be checked for validity. This is only recommended for testing purposes when working with self-signed certificates. |
| `connectTimeout` — Connect timeout in ms | int | Error Handling | — | The timeout for establishing the socket connection in milliseconds. A timeout of zero is interpreted as an infinite timeout. |
| `readTimeout` — Read timeout in ms | int | Error Handling | — | The timeout for reading data from the socket connection in milliseconds. A timeout of zero is interpreted as an infinite timeout. |
| `file` — File | File | Configuration | — | The file that will be uploaded. |
| `url` — URL | String | Configuration | — | The URL to which the file should be uploaded. The URL must start with http:// or https://. If you add a query string, it must already be URL encoded. |
| `requestHeaders` — Request headers | List [context=requestHeaders] | Configuration | — | A list of name-value pairs that should be set as additional headers for the request. Request headers that are installer variables with array or collection values (e.g. String[], Object[] or List<File>) are expanded as separate request headers, this allows you to build a variable length list of request headers at runtime. |
| `logRequestHeaders` — Log request headers | boolean | Configuration | — | If the request headers should be written into the log file or not. Disabled by default due to security reasons. |
| `uploadMethod` — Upload method | [HttpUploadMethod](enums.md#httpuploadmethod) | Configuration | — | The request method for the HTTP protocol can be one of POST, PUT. |
| `retryIfInterrupted` — Retry if interrupted | boolean | Configuration | — | If selected, ask the user to retry if a successfully started upload is interrupted. |
| `showProgress` — Show progress | boolean | Configuration | — | If selected, and a progress bar is available on the current screen, the action will show its progress in the progress bar. |
| `showFileName` — Show file name | boolean | Configuration | `showProgress`=true | If selected, the name of the uploaded file and the target directory will be displayed. This setting has no effect if "Show progress" is not selected. |

### Wait for HTTP server
- **Class:** `com.install4j.runtime.beans.actions.net.WaitForHttpServerAction`
- **Category:** HTTP and network
- **Multiple instances:** yes

Wait until an HTTP or HTTPS port becomes available. This is useful if you start a server, for example with a "Start a service" action, and need to wait until the server is operational before proceeding with the installation.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `timeout` — Timeout | int | Configuration | — | The timeout in seconds. After this timeout, the action will give up waiting for the HTTP port and fail. A timeout of 0 or a negative value means that the action will wait indefinitely for the HTTP port. |
| `indeterminateProgress` — Set indeterminate progress | boolean | Configuration | — | If selected, the progress bar will be set to indeterminate mode while the action is running. Note that this only has an effect if a progress bar is available on the current screen. |
| `url` — URL | String | Configuration | — | The URL that should be checked. The URL must start with http:// or https://. If you add a query string, it must already be URL encoded. |
| `timeout` — Timeout | int | Configuration | — | The timeout in seconds. After this timeout, the action will give up waiting for the HTTP port and fail. A timeout of 0 or a negative value means that the action will wait indefinitely for the HTTP port. |
| `indeterminateProgress` — Set indeterminate progress | boolean | Configuration | — | If selected, the progress bar will be set to indeterminate mode while the action is running. Note that this only has an effect if a progress bar is available on the current screen. |
| `acceptAllResponseCodes` — Accept all response codes | boolean | Configuration | — | If selected, all response codes returned by the HTTP server will be accepted for the action to succeed. Otherwise, the action will continue to wait for a 2xx response code. |
| `responseCodeVariableName` — Variable name for response code | String [context=variableName] (variable→ Integer) | Configuration | — | If set, the response code will be saved to this installer variable. The variable will only be set in case of success. If the action fails, it always fails due to the timeout and there is no associated response code. |

### Wait for Socket
- **Class:** `com.install4j.runtime.beans.actions.net.WaitForSocketAction`
- **Category:** HTTP and network
- **Multiple instances:** yes

Wait until a socket can be connected to. This is useful if you start a non-HTTP server. For HTTP and HTTPS, use the "Wait for HTTP server" action instead.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `timeout` — Timeout | int | Configuration | — | The timeout in seconds. After this timeout, the action will give up waiting for the HTTP port and fail. A timeout of 0 or a negative value means that the action will wait indefinitely for the HTTP port. |
| `indeterminateProgress` — Set indeterminate progress | boolean | Configuration | — | If selected, the progress bar will be set to indeterminate mode while the action is running. Note that this only has an effect if a progress bar is available on the current screen. |
| `host` — URL | String | Configuration | — | The host on which the server socket should be checked. Can be a host name or an IP address. |
| `port` — Port | String | Configuration | — | The port on which the server socket should be checked. |
| `timeout` — Timeout | int | Configuration | — | The timeout in seconds. After this timeout, the action will give up waiting for the HTTP port and fail. A timeout of 0 or a negative value means that the action will wait indefinitely for the HTTP port. |
| `indeterminateProgress` — Set indeterminate progress | boolean | Configuration | — | If selected, the progress bar will be set to indeterminate mode while the action is running. Note that this only has an effect if a progress bar is available on the current screen. |

