public class OkHttpDownloadAction extends AbstractDownloadAction
DownloadAction.
Created by covers1624 on 20/11/21.
DownloadAction.Destdest, downloadListener, headers, onlyIfModified, quiet, upToDate, url, useETag, userAgent| Constructor and Description |
|---|
OkHttpDownloadAction() |
| Modifier and Type | Method and Description |
|---|---|
OkHttpDownloadAction |
addRequestHeader(java.lang.String key,
java.lang.String value)
Adds an arbitrary Http header to the action.
|
OkHttpDownloadAction |
addTag(java.lang.Class<?> clazz,
java.lang.Object tag)
Add a Tag to the OkHttp
Request. |
void |
execute()
Execute the download action.
|
okhttp3.OkHttpClient |
getClient() |
java.util.Map<java.lang.Class<?>,java.lang.Object> |
getTags() |
OkHttpDownloadAction |
setClient(okhttp3.OkHttpClient client)
Set the
OkHttpClient client to use. |
OkHttpDownloadAction |
setDest(DownloadAction.Dest dest)
Set the Destination to download content to.
|
OkHttpDownloadAction |
setDest(java.io.File file)
Set the
File to download content to. |
OkHttpDownloadAction |
setDest(java.io.OutputStream os)
Set the
OutputStream to download content to. |
OkHttpDownloadAction |
setDest(java.nio.file.Path path)
Set the
Path to download content to. |
OkHttpDownloadAction |
setDest(java.io.StringWriter sw)
Set the
StringWriter to download content to. |
OkHttpDownloadAction |
setDownloadListener(DownloadListener downloadListener)
Set the
DownloadListener to use. |
OkHttpDownloadAction |
setOnlyIfModified(boolean onlyIfModified)
If this Download action should use
If-Modified-Since
HTTP request header. |
OkHttpDownloadAction |
setQuiet(boolean quiet)
If this download action should not log things.
|
OkHttpDownloadAction |
setUrl(java.lang.String url)
Set the URL to download from.
|
OkHttpDownloadAction |
setUseETag(boolean useETag)
If this download action should use
If-None-Match
HTTP request header. |
OkHttpDownloadAction |
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
java.io.IOException - If an IO error occurs whilst downloading.HttpResponseException - If the response code was not expected.public OkHttpDownloadAction setClient(okhttp3.OkHttpClient client)
OkHttpClient client to use.client - The OkHttpClient.public OkHttpDownloadAction addTag(java.lang.Class<?> clazz, java.lang.Object tag)
Request.clazz - The Tag type.tag - The tag.public OkHttpDownloadAction setUrl(java.lang.String url)
DownloadActionsetUrl in interface DownloadActionsetUrl in class AbstractDownloadActionurl - The URL.public OkHttpDownloadAction setDest(DownloadAction.Dest dest)
DownloadActionsetDest in interface DownloadActionsetDest in class AbstractDownloadActiondest - The Destination.public OkHttpDownloadAction setDest(java.io.StringWriter sw)
DownloadActionStringWriter to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionsw - The StringWriter.public OkHttpDownloadAction setDest(java.io.OutputStream os)
DownloadActionOutputStream to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionos - The OutputStream.public OkHttpDownloadAction setDest(java.io.File file)
DownloadActionFile to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionfile - The file.public OkHttpDownloadAction setDest(java.nio.file.Path path)
DownloadActionPath to download content to.setDest in interface DownloadActionsetDest in class AbstractDownloadActionpath - The path.public OkHttpDownloadAction setOnlyIfModified(boolean onlyIfModified)
DownloadActionIf-Modified-Since
HTTP request header.setOnlyIfModified in interface DownloadActionsetOnlyIfModified in class AbstractDownloadActiononlyIfModified - If If-Modified-Since should be used.public OkHttpDownloadAction setUseETag(boolean useETag)
DownloadActionIf-None-Match
HTTP request header.setUseETag in interface DownloadActionsetUseETag in class AbstractDownloadActionuseETag - If If-None-Match should be used.public OkHttpDownloadAction setQuiet(boolean quiet)
DownloadActionsetQuiet in interface DownloadActionsetQuiet in class AbstractDownloadActionquiet - If the download action should be quiet.public OkHttpDownloadAction setUserAgent(java.lang.String userAgent)
DownloadActionUser-Agent HTTP request header.setUserAgent in interface DownloadActionsetUserAgent in class AbstractDownloadActionuserAgent - The User-Agent request header.public OkHttpDownloadAction addRequestHeader(java.lang.String key, java.lang.String value)
DownloadActionaddRequestHeader in interface DownloadActionaddRequestHeader in class AbstractDownloadActionkey - The key.value - The value.public OkHttpDownloadAction setDownloadListener(DownloadListener downloadListener)
DownloadActionDownloadListener to use.setDownloadListener in interface DownloadActionsetDownloadListener in class AbstractDownloadActiondownloadListener - The DownloadListener.public okhttp3.OkHttpClient getClient()
public java.util.Map<java.lang.Class<?>,java.lang.Object> getTags()