public class HttpUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE |
static java.nio.charset.Charset |
HTTP_DEFAULT_CHAR_ENCODUNG |
static int |
HTTP_DEFAULT_PORT |
static java.lang.String |
HTTP_PREFIX |
static int |
HTTPS_DEFAULT_PORT |
static java.lang.String |
HTTPS_PREFIX |
static HttpUtil |
HU |
static java.lang.String |
SCHEME_HOST_SEPARATOR |
static java.lang.String |
SCHEME_HTTP |
static java.lang.String |
SCHEME_HTTPS |
Modifier | Constructor and Description |
---|---|
protected |
HttpUtil() |
Modifier and Type | Method and Description |
---|---|
static HttpUtil |
current()
Returns the only instance this class supports (design pattern "Singleton")
|
long |
download(ClientRequest request,
java.io.OutputStream outputStream,
java.net.Proxy proxy,
int bufferSize,
IProgressListener listener)
Downloads the content of the specified URL and stores it into the given stream.
|
long |
download(java.net.URL url,
java.io.File file)
Downloads (via GET request) the content of the specified URL and stores it into the given file.
|
long |
download(java.net.URL url,
java.io.File file,
IProgressListener listener)
Downloads (via GET request) the content of the specified URL and stores it into the given file.
|
long |
download(java.net.URL url,
java.io.File file,
java.net.Proxy proxy)
Downloads (via GET request) the content of the specified URL and stores it into the given file.
|
long |
download(java.net.URL url,
java.io.File file,
java.net.Proxy proxy,
int bufferSize,
IProgressListener listener)
Downloads (via GET request) the content of the specified URL and stores it into the given file.
|
long |
download(java.net.URL url,
java.io.File file,
java.net.Proxy proxy,
IProgressListener listener)
Downloads (via GET request) the content of the specified URL and stores it into the given file.
|
long |
download(java.net.URL url,
java.io.OutputStream outputStream,
java.net.Proxy proxy,
int bufferSize,
IProgressListener listener)
Downloads (via GET request) the content of the specified URL and stores it into the given stream.
|
long |
download(UserAgent userAgent,
ClientRequest request,
java.io.OutputStream outputStream,
int bufferSize,
IProgressListener listener)
Downloads the content of the specified URL and stores it into the given stream.
|
long |
download(UserAgent userAgent,
java.net.URL url,
java.io.File file)
Downloads (via GET request) the content of the specified URL and stores it into the given file.
|
long |
download(UserAgent userAgent,
java.net.URL url,
java.io.File file,
int bufferSize,
IProgressListener listener)
Downloads (via GET request) the content of the specified URL and stores it into the given file.
|
long |
download(UserAgent userAgent,
java.net.URL url,
java.io.File file,
IProgressListener listener)
Downloads (via GET request) the content of the specified URL and stores it into the given file.
|
protected IOUtil |
ioUtil() |
boolean |
isHttpsURL(java.lang.String url)
Returns whether or not the given string starts with a proper HTTPS protocol
prefix.
|
boolean |
isHttpURL(java.lang.String url)
Returns whether or not the given string starts with a proper HTTP protocol
prefix.
|
AuthorizationHeader |
parseAuthorizationHeaderValue(java.lang.String headerValue)
Parses the given header value according to the rules of an Authorization header.
|
protected StringUtil |
stringUtil() |
public static final HttpUtil HU
public static final java.nio.charset.Charset HTTP_DEFAULT_CHAR_ENCODUNG
public static final java.lang.String SCHEME_HOST_SEPARATOR
public static final java.lang.String SCHEME_HTTP
public static final java.lang.String SCHEME_HTTPS
public static final java.lang.String HTTP_PREFIX
public static final java.lang.String HTTPS_PREFIX
public static final int HTTP_DEFAULT_PORT
public static final int HTTPS_DEFAULT_PORT
public static final int DEFAULT_BUFFER_SIZE
public static HttpUtil current()
public boolean isHttpURL(java.lang.String url)
public boolean isHttpsURL(java.lang.String url)
public AuthorizationHeader parseAuthorizationHeaderValue(java.lang.String headerValue)
headerValue
- The header value to be parsed (may be null).public long download(java.net.URL url, java.io.File file) throws java.io.IOException
url
- A valid HTTP or HTTPS URL that can be used to execute a GET request.file
- The file into which the downloaded content should be stored.java.io.IOException
- If any reading of writing fails.public long download(UserAgent userAgent, java.net.URL url, java.io.File file) throws java.io.IOException
userAgent
- The user agent to do act as client for the download.url
- A valid HTTP or HTTPS URL that can be used to execute a GET request.file
- The file into which the downloaded content should be stored.java.io.IOException
- If any reading of writing fails.public long download(java.net.URL url, java.io.File file, IProgressListener listener) throws java.io.IOException
url
- A valid HTTP or HTTPS URL that can be used to execute a GET request.file
- The file into which the downloaded content should be stored.listener
- An optional progress listener to display progress or cancel the download.java.io.IOException
- If any reading of writing fails.public long download(java.net.URL url, java.io.File file, java.net.Proxy proxy) throws java.io.IOException
url
- A valid HTTP or HTTPS URL that can be used to execute a GET request.file
- The file into which the downloaded content should be stored.java.io.IOException
- If any reading of writing fails.public long download(java.net.URL url, java.io.File file, java.net.Proxy proxy, IProgressListener listener) throws java.io.IOException
url
- A valid HTTP or HTTPS URL that can be used to execute a GET request.file
- The file into which the downloaded content should be stored.listener
- An optional progress listener to display progress or cancel the download.java.io.IOException
- If any reading of writing fails.public long download(UserAgent userAgent, java.net.URL url, java.io.File file, IProgressListener listener) throws java.io.IOException
userAgent
- The user agent to do act as client for the download.url
- A valid HTTP or HTTPS URL that can be used to execute a GET request.file
- The file into which the downloaded content should be stored.listener
- An optional progress listener to display progress or cancel the download.java.io.IOException
- If any reading of writing fails.public long download(java.net.URL url, java.io.File file, java.net.Proxy proxy, int bufferSize, IProgressListener listener) throws java.io.IOException
url
- A valid HTTP or HTTPS URL that can be used to execute a GET request.file
- The file into which the downloaded content should be stored.bufferSize
- The size of the buffer (usually larger buffer - better performance).listener
- An optional progress listener to display progress or cancel the download.java.io.IOException
- If any reading of writing fails.public long download(UserAgent userAgent, java.net.URL url, java.io.File file, int bufferSize, IProgressListener listener) throws java.io.IOException
userAgent
- The user agent to do act as client for the download.url
- A valid HTTP or HTTPS URL that can be used to execute a GET request.file
- The file into which the downloaded content should be stored.bufferSize
- The size of the buffer (usually larger buffer - better performance).listener
- An optional progress listener to display progress or cancel the download.java.io.IOException
- If any reading of writing fails.public long download(java.net.URL url, java.io.OutputStream outputStream, java.net.Proxy proxy, int bufferSize, IProgressListener listener) throws java.io.IOException
url
- A valid HTTP or HTTPS URL that can be used to execute a GET request.outputStream
- The stream into which the downloaded content should be stored.bufferSize
- The size of the buffer (usually larger buffer - better performance).listener
- An optional progress listener to display progress or cancel the download.java.io.IOException
- If any reading of writing fails.public long download(ClientRequest request, java.io.OutputStream outputStream, java.net.Proxy proxy, int bufferSize, IProgressListener listener) throws java.io.IOException
request
- A valid HTTP or HTTPS request that can be used to execute the download.outputStream
- The stream into which the downloaded content should be stored.bufferSize
- The size of the buffer (usually larger buffer - better performance).listener
- An optional progress listener to display progress or cancel the download.java.io.IOException
- If any reading of writing fails.public long download(UserAgent userAgent, ClientRequest request, java.io.OutputStream outputStream, int bufferSize, IProgressListener listener) throws java.io.IOException
userAgent
- The user agent to do act as client for the download.request
- A valid HTTP or HTTPS request that can be used to execute the download.outputStream
- The stream into which the downloaded content should be stored.bufferSize
- The size of the buffer (usually larger buffer - better performance).listener
- An optional progress listener to display progress or cancel the download.java.io.IOException
- If any reading of writing fails.protected StringUtil stringUtil()
protected IOUtil ioUtil()