public class ApacheHttpClientDownloadAction extends AbstractDownloadAction
DownloadAction.
Created by covers1624 on 22/11/21.
DownloadAction.Destdest, downloadListener, headers, onlyIfModified, quiet, upToDate, url, useETag, userAgent| Constructor and Description |
|---|
ApacheHttpClientDownloadAction() |
| Modifier and Type | Method and Description |
|---|---|
ApacheHttpClientDownloadAction |
addRequestHeader(java.lang.String key,
java.lang.String value)
Adds an arbitrary Http header to the action.
|
void |
execute()
Execute the download action.
|
org.apache.http.impl.client.CloseableHttpClient |
getClient() |
ApacheHttpClientDownloadAction |
setClient(org.apache.http.impl.client.CloseableHttpClient client)
Set the
CloseableHttpClient client to use. |
ApacheHttpClientDownloadAction |
setDest(DownloadAction.Dest dest)
Set the Destination to download content to.
|
ApacheHttpClientDownloadAction |
setDest(java.io.File file)
Set the
File to download content to. |
ApacheHttpClientDownloadAction |
setDest(java.io.OutputStream os)
Set the
OutputStream to download content to. |
ApacheHttpClientDownloadAction |
setDest(java.nio.file.Path path)
Set the
Path to download content to. |
ApacheHttpClientDownloadAction |
setDest(java.io.StringWriter sw)
Set the
StringWriter to download content to. |
ApacheHttpClientDownloadAction |
setDownloadListener(DownloadListener downloadListener)
Set the
DownloadListener to use. |
ApacheHttpClientDownloadAction |
setOnlyIfModified(boolean onlyIfModified)
If this Download action should use
If-Modified-Since
HTTP request header. |
ApacheHttpClientDownloadAction |
setQuiet(boolean quiet)
If this download action should not log things.
|
ApacheHttpClientDownloadAction |
setUrl(java.lang.String url)
Set the URL to download from.
|
ApacheHttpClientDownloadAction |
setUseETag(boolean useETag)
If this download action should use
If-None-Match
HTTP request header. |
ApacheHttpClientDownloadAction |
setUserAgent(java.lang.String userAgent)
Sets the
User-Agent HTTP request header. |
calcUpToDate, expectNotModified, getDest, getDownloadListener, getOnlyIfModified, getQuiet, getUrl, getUseETag, getUserAgent, isUpToDate, validateCodepublic void execute()
throws java.io.IOException
DownloadActionjava.io.IOException - If an IO error occurs whilst downloading.HttpResponseException - If the response code was not expected.public ApacheHttpClientDownloadAction setClient(org.apache.http.impl.client.CloseableHttpClient client)
CloseableHttpClient client to use.client - The CloseableHttpClient.public ApacheHttpClientDownloadAction setUrl(java.lang.String url)
DownloadActionsetUrl in interface DownloadActionsetUrl in class AbstractDownloadActionurl - The URL.public ApacheHttpClientDownloadAction setDest(DownloadAction.Dest dest)
DownloadActionsetDest in interface DownloadActionsetDest in class AbstractDownloadActiondest - The Destination.public ApacheHttpClientDownloadAction setDest(java.io.StringWriter sw)
DownloadActionStringWriter to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionsw - The StringWriter.public ApacheHttpClientDownloadAction setDest(java.io.OutputStream os)
DownloadActionOutputStream to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionos - The OutputStream.public ApacheHttpClientDownloadAction setDest(java.io.File file)
DownloadActionFile to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionfile - The file.public ApacheHttpClientDownloadAction setDest(java.nio.file.Path path)
DownloadActionPath to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionpath - The path.public ApacheHttpClientDownloadAction setOnlyIfModified(boolean onlyIfModified)
DownloadActionIf-Modified-Since
HTTP request header.setOnlyIfModified in interface DownloadActionsetOnlyIfModified in class AbstractDownloadActiononlyIfModified - If If-Modified-Since should be used.public ApacheHttpClientDownloadAction setUseETag(boolean useETag)
DownloadActionIf-None-Match
HTTP request header.setUseETag in interface DownloadActionsetUseETag in class AbstractDownloadActionuseETag - If If-None-Match should be used.public ApacheHttpClientDownloadAction setQuiet(boolean quiet)
DownloadActionsetQuiet in interface DownloadActionsetQuiet in class AbstractDownloadActionquiet - If the download action should be quiet.public ApacheHttpClientDownloadAction addRequestHeader(java.lang.String key, java.lang.String value)
DownloadActionaddRequestHeader in interface DownloadActionaddRequestHeader in class AbstractDownloadActionkey - The key.value - The value.public ApacheHttpClientDownloadAction setUserAgent(java.lang.String userAgent)
DownloadActionUser-Agent HTTP request header.setUserAgent in interface DownloadActionsetUserAgent in class AbstractDownloadActionuserAgent - The User-Agent request header.public ApacheHttpClientDownloadAction setDownloadListener(DownloadListener downloadListener)
DownloadActionDownloadListener to use.setDownloadListener in interface DownloadActionsetDownloadListener in class AbstractDownloadActiondownloadListener - The DownloadListener.public org.apache.http.impl.client.CloseableHttpClient getClient()