Modifier and Type | Class and Description |
---|---|
static class |
HttpUtils.MetaRefreshRedirectStrategy
A
RedirectStrategy that can deal with meta-refresh style
redirection |
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_USERAGENT
The default user-agent string
|
Modifier and Type | Method and Description |
---|---|
static InputStream |
readURL(URL url)
Open an
HttpURLConnection to the URL as an array of
bytes. |
static InputStream |
readURL(URL url,
boolean followRedirects)
Open an
HttpURLConnection to the URL as an array of
bytes. |
static <T extends org.openimaj.io.InternalReadable> |
readURL(URL url,
Class<? extends T> clz)
Read the an object from the given URL.
|
static <T,Q extends InputStreamObjectReader<T>> |
readURL(URL url,
Q reader)
Read the an object from the given URL.
|
static <T extends org.openimaj.io.InternalReadable> |
readURL(URL url,
T obj)
Read the internal state of an object from the given URL.
|
static IndependentPair<org.apache.http.HttpEntity,ByteArrayInputStream> |
readURLAsByteArrayInputStream(URL u,
boolean followRedirects)
Read the contents of the given
URL as a
ByteArrayInputStream (i.e. |
static IndependentPair<org.apache.http.HttpEntity,ByteArrayInputStream> |
readURLAsByteArrayInputStream(URL url,
int connectionTimeout,
int readTimeout,
org.apache.http.client.RedirectStrategy redirectStrategy,
String userAgent)
Read the contents of the given
URL as a
ByteArrayInputStream (i.e. |
static IndependentPair<org.apache.http.HttpEntity,ByteArrayInputStream> |
readURLAsByteArrayInputStream(URL u,
org.apache.http.client.RedirectStrategy strategy)
Read the contents of the given
URL as a
ByteArrayInputStream (i.e. |
static byte[] |
readURLAsBytes(URL u)
Read the contents of the given
URL as an array of bytes. |
static byte[] |
readURLAsBytes(URL u,
boolean followRedirects)
Read the contents of the given
URL as an array of bytes. |
static InputStream |
readURLAsStream(URL url)
Open a
InputStream to the contents referenced by the URL . |
static InputStream |
readURLAsStream(URL url,
boolean followRedirects)
Open a
InputStream to the contents referenced by the URL . |
public static final String DEFAULT_USERAGENT
public static byte[] readURLAsBytes(URL u) throws IOException
URL
as an array of bytes.
Redirects are followed automatically.u
- the URL to read fromIOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static byte[] readURLAsBytes(URL u, boolean followRedirects) throws IOException
URL
as an array of bytes. If
redirects are not being followed, then the result will be null if the URL
is redirected.u
- the URL to read fromfollowRedirects
- should redirects be followed?IOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static IndependentPair<org.apache.http.HttpEntity,ByteArrayInputStream> readURLAsByteArrayInputStream(URL u, boolean followRedirects) throws IOException
URL
as a
ByteArrayInputStream
(i.e. a byte[] in memory wrapped in an
InputStream
). If redirects are not being followed, then the
result will be null if the URL is redirected.u
- the URL to read fromfollowRedirects
- should redirects be followed?IOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static IndependentPair<org.apache.http.HttpEntity,ByteArrayInputStream> readURLAsByteArrayInputStream(URL u, org.apache.http.client.RedirectStrategy strategy) throws IOException
URL
as a
ByteArrayInputStream
(i.e. a byte[] in memory wrapped in an
InputStream
). If redirects are not being followed, then the
result will be null if the URL is redirected.u
- the URL to read fromstrategy
- how redirects should be followedIOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static IndependentPair<org.apache.http.HttpEntity,ByteArrayInputStream> readURLAsByteArrayInputStream(URL url, int connectionTimeout, int readTimeout, org.apache.http.client.RedirectStrategy redirectStrategy, String userAgent) throws IOException
URL
as a
ByteArrayInputStream
(i.e. a byte[] in memory wrapped in an
InputStream
). If redirects are not being followed, then the
result will be null if the URL is redirected.url
- the URL to read fromconnectionTimeout
- amount of time to wait for connectionreadTimeout
- amount of time to wait for readingredirectStrategy
- the redirection strategyuserAgent
- the useragent stringIOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static InputStream readURL(URL url) throws IOException
HttpURLConnection
to the URL
as an array of
bytes. Redirects are followed automatically.url
- the URL to read fromIOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static InputStream readURL(URL url, boolean followRedirects) throws IOException
HttpURLConnection
to the URL
as an array of
bytes.url
- the URL to read fromfollowRedirects
- should redirects be followed?IOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static InputStream readURLAsStream(URL url) throws IOException
InputStream
to the contents referenced by the URL
.
Redirects are followed automatically.url
- the URL to read fromIOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static InputStream readURLAsStream(URL url, boolean followRedirects) throws IOException
InputStream
to the contents referenced by the URL
.
If redirects are not being followed, then the result will be null if the
URL is redirected.url
- the URL to read fromfollowRedirects
- should redirects be followed.IOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static <T extends org.openimaj.io.InternalReadable> T readURL(URL url, T obj) throws IOException
T
- Type of object being read.url
- the URL to read fromobj
- the object to fillIOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static <T extends org.openimaj.io.InternalReadable> T readURL(URL url, Class<? extends T> clz) throws IOException
T
- Type of object being read.url
- the URL to read fromclz
- the class of the object to readIOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URLpublic static <T,Q extends InputStreamObjectReader<T>> T readURL(URL url, Q reader) throws IOException
T
- Type of object being read.Q
- Type of the object reader.url
- the URL to read fromreader
- the reader that creates the object.IOException
- if an error occursIllegalArgumentException
- if the URL is not an HTTP(s) URL