de.undercouch.gradle.tasks.download
Interface DownloadSpec

All Known Implementing Classes:
Download, DownloadAction

public interface DownloadSpec

An interface for classes that perform file downloads


Method Summary
 void acceptAnyCertificate(boolean accept)
          Specifies if HTTPS certificate verification errors should be ignored and any certificate (even an invalid one) should be accepted.
 void authScheme(java.lang.Object authScheme)
          Sets the authentication scheme to use.
 void compress(boolean compress)
          Specifies if compression should be used during download
 void credentials(org.apache.http.auth.Credentials credentials)
          Sets the credentials used for authentication.
 void dest(java.lang.Object dest)
          Sets the download destination
 org.apache.http.auth.AuthScheme getAuthScheme()
           
 org.apache.http.auth.Credentials getCredentials()
           
 java.io.File getDest()
           
 java.lang.String getHeader(java.lang.String name)
           
 java.util.Map<java.lang.String,java.lang.String> getHeaders()
           
 java.lang.String getPassword()
           
 org.apache.http.HttpRequestInterceptor getRequestInterceptor()
           
 org.apache.http.HttpResponseInterceptor getResponseInterceptor()
           
 java.lang.Object getSrc()
           
 int getTimeout()
           
 java.lang.String getUsername()
           
 void header(java.lang.String name, java.lang.String value)
          Sets an HTTP request header to use when downloading
 void headers(java.util.Map<java.lang.String,java.lang.String> headers)
          Sets the HTTP request headers to use when downloading
 boolean isAcceptAnyCertificate()
           
 boolean isCompress()
           
 boolean isOnlyIfModified()
           
 boolean isOnlyIfNewer()
          Get the onlyIfNewer flag.
 boolean isOverwrite()
           
 boolean isQuiet()
           
 void onlyIfModified(boolean onlyIfModified)
          Sets the onlyIfModified flag
 void onlyIfNewer(boolean onlyIfNewer)
          Sets the onlyIfNewer flag.
 void overwrite(boolean overwrite)
          Sets the overwrite flag
 void password(java.lang.String password)
          Sets the password for Basic or Digest authentication
 void quiet(boolean quiet)
          Sets the quiet flag
 void requestInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
          Specifies an interceptor that will be called when a request is about to be sent to the server.
 void responseInterceptor(org.apache.http.HttpResponseInterceptor interceptor)
          Specifies an interceptor that will be called when a response has been received from the server.
 void src(java.lang.Object src)
          Sets the download source URL
 void timeout(int milliseconds)
          Specifies a timeout in milliseconds which is the maximum time to wait until a connection is established or until the server returns data.
 void username(java.lang.String username)
          Sets the username for Basic or Digest authentication
 

Method Detail

src

void src(java.lang.Object src)
         throws java.net.MalformedURLException
Sets the download source URL

Parameters:
src - the URL
Throws:
java.net.MalformedURLException - if the download source is not a URL

dest

void dest(java.lang.Object dest)
Sets the download destination

Parameters:
dest - a file or directory where to store the retrieved file

quiet

void quiet(boolean quiet)
Sets the quiet flag

Parameters:
quiet - true if download progress should not be logged

overwrite

void overwrite(boolean overwrite)
Sets the overwrite flag

Parameters:
overwrite - true if existing files should be overwritten, false otherwise

onlyIfModified

void onlyIfModified(boolean onlyIfModified)
Sets the onlyIfModified flag

Parameters:
onlyIfModified - true if the file should only be downloaded if it has been modified on the server since the last download

onlyIfNewer

void onlyIfNewer(boolean onlyIfNewer)
Sets the onlyIfNewer flag. This method is an alias for onlyIfModified(boolean).

Parameters:
onlyIfNewer - true if the file should only be downloaded if it has been modified on the server since the last download

compress

void compress(boolean compress)
Specifies if compression should be used during download

Parameters:
compress - true if compression should be enabled

username

void username(java.lang.String username)
Sets the username for Basic or Digest authentication

Parameters:
username - the username

password

void password(java.lang.String password)
Sets the password for Basic or Digest authentication

Parameters:
password - the password

authScheme

void authScheme(java.lang.Object authScheme)

Sets the authentication scheme to use. This method accepts either a String (valid values are "Basic" and "Digest") or an instance of AuthScheme.

If username and password are set this method will only accept "Basic" or "Digest" as valid values. The default value will be "Basic" in this case.

Parameters:
authScheme - the authentication scheme

credentials

void credentials(org.apache.http.auth.Credentials credentials)
Sets the credentials used for authentication. Can be called as an alternative to username(String) and password(String). Allows for setting credentials for authentication schemes other than Basic or Digest.

Parameters:
credentials - the credentials

headers

void headers(java.util.Map<java.lang.String,java.lang.String> headers)
Sets the HTTP request headers to use when downloading

Parameters:
headers - a Map of header names to values

header

void header(java.lang.String name,
            java.lang.String value)
Sets an HTTP request header to use when downloading

Parameters:
name - name of the HTTP header
value - value of the HTTP header

acceptAnyCertificate

void acceptAnyCertificate(boolean accept)
Specifies if HTTPS certificate verification errors should be ignored and any certificate (even an invalid one) should be accepted. By default certificates are validated and errors are not being ignored.

Parameters:
accept - true if certificate errors should be ignored (default: false)

timeout

void timeout(int milliseconds)
Specifies a timeout in milliseconds which is the maximum time to wait until a connection is established or until the server returns data. A value of zero means infinite timeout. A negative value is interpreted as undefined.

Parameters:
milliseconds - the timeout in milliseconds (default: -1)

requestInterceptor

void requestInterceptor(org.apache.http.HttpRequestInterceptor interceptor)
Specifies an interceptor that will be called when a request is about to be sent to the server. This is useful if you want to manipulate a request beyond the capabilities of the download task.

Parameters:
interceptor - the interceptor to set

responseInterceptor

void responseInterceptor(org.apache.http.HttpResponseInterceptor interceptor)
Specifies an interceptor that will be called when a response has been received from the server. This is useful if you want to manipulate incoming data before it is handled by the download task.

Parameters:
interceptor - the interceptor to set

getSrc

java.lang.Object getSrc()
Returns:
the download source(s), either a URL or a list of URLs

getDest

java.io.File getDest()
Returns:
the download destination

isQuiet

boolean isQuiet()
Returns:
the quiet flag

isOverwrite

boolean isOverwrite()
Returns:
the overwrite flag

isOnlyIfModified

boolean isOnlyIfModified()
Returns:
the onlyIfModified flag

isOnlyIfNewer

boolean isOnlyIfNewer()
Get the onlyIfNewer flag. This method is an alias for isOnlyIfModified().

Returns:
the onlyIfNewer flag

isCompress

boolean isCompress()
Returns:
true if compression is enabled

getUsername

java.lang.String getUsername()
Returns:
the username for Basic or Digest authentication

getPassword

java.lang.String getPassword()
Returns:
the password for Basic or Digest authentication

getAuthScheme

org.apache.http.auth.AuthScheme getAuthScheme()
Returns:
the authentication scheme used (or null if no authentication is performed)

getCredentials

org.apache.http.auth.Credentials getCredentials()
Returns:
the credentials used for authentication (or null if no authentication is performed)

getHeaders

java.util.Map<java.lang.String,java.lang.String> getHeaders()
Returns:
the HTTP request headers to use when downloading

getHeader

java.lang.String getHeader(java.lang.String name)
Parameters:
name - name of the HTTP header
Returns:
the value of the HTTP header

isAcceptAnyCertificate

boolean isAcceptAnyCertificate()
Returns:
true if HTTPS certificate verification errors should be ignored, default value is false

getTimeout

int getTimeout()
Returns:
the timeout in milliseconds which is the maximum time to wait until a connection is established or until the server returns data.

getRequestInterceptor

org.apache.http.HttpRequestInterceptor getRequestInterceptor()
Returns:
an interceptor that will be called when a request is about to be sent to the server (or null if no interceptor is specified)

getResponseInterceptor

org.apache.http.HttpResponseInterceptor getResponseInterceptor()
Returns:
an interceptor that will be called when a response has been received from the server (or null if no interceptor is specified)