@ThreadSafe public class DefaultResourceRetriever extends AbstractRestrictedResourceRetriever implements RestrictedResourceRetriever
Constructor and Description |
---|
DefaultResourceRetriever()
Creates a new resource retriever.
|
DefaultResourceRetriever(int connectTimeout,
int readTimeout)
Creates a new resource retriever.
|
DefaultResourceRetriever(int connectTimeout,
int readTimeout,
int sizeLimit)
Creates a new resource retriever.
|
DefaultResourceRetriever(int connectTimeout,
int readTimeout,
int sizeLimit,
boolean disconnectAfterUse)
Creates a new resource retriever.
|
Modifier and Type | Method and Description |
---|---|
boolean |
disconnectsAfterUse()
Returns
true if the disconnect method of the underlying
HttpURLConnection will be called after trying to retrieve
the resource. |
Proxy |
getProxy()
Returns the HTTP proxy to use when opening the HttpURLConnection to
retrieve the resource.
|
protected HttpURLConnection |
openConnection(URL url)
Opens a connection the specified HTTP(S) URL.
|
Resource |
retrieveResource(URL url)
Retrieves the resource from the specified HTTP(S) URL.
|
void |
setDisconnectsAfterUse(boolean disconnectAfterUse)
Controls calling of the disconnect method the underlying
HttpURLConnection after trying to retrieve the resource. |
void |
setProxy(Proxy proxy)
Sets the HTTP proxy to use when opening the HttpURLConnection to
retrieve the resource.
|
getConnectTimeout, getHeaders, getReadTimeout, getSizeLimit, setConnectTimeout, setHeaders, setReadTimeout, setSizeLimit
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConnectTimeout, getHeaders, getReadTimeout, getSizeLimit, setConnectTimeout, setHeaders, setReadTimeout, setSizeLimit
public DefaultResourceRetriever()
public DefaultResourceRetriever(int connectTimeout, int readTimeout)
connectTimeout
- The HTTP connects timeout, in milliseconds,
zero for infinite. Must not be negative.readTimeout
- The HTTP read timeout, in milliseconds, zero
for infinite. Must not be negative.public DefaultResourceRetriever(int connectTimeout, int readTimeout, int sizeLimit)
connectTimeout
- The HTTP connects timeout, in milliseconds,
zero for infinite. Must not be negative.readTimeout
- The HTTP read timeout, in milliseconds, zero
for infinite. Must not be negative.sizeLimit
- The HTTP entity size limit, in bytes, zero for
infinite. Must not be negative.public DefaultResourceRetriever(int connectTimeout, int readTimeout, int sizeLimit, boolean disconnectAfterUse)
connectTimeout
- The HTTP connects timeout, in
milliseconds, zero for infinite. Must not
be negative.readTimeout
- The HTTP read timeout, in milliseconds,
zero for infinite. Must not be negative.sizeLimit
- The HTTP entity size limit, in bytes, zero
for infinite. Must not be negative.disconnectAfterUse
- If true
the disconnect method of
the underlying HttpURLConnection
will be called after trying to retrieve
the resource. Whether the TCP socket is
actually closed or reused depends on the
underlying HTTP implementation and the
setting of the keep.alive
system
property.public boolean disconnectsAfterUse()
true
if the disconnect method of the underlying
HttpURLConnection
will be called after trying to retrieve
the resource. Whether the TCP socket is actually closed or reused
depends on the underlying HTTP implementation and the setting of the
keep.alive
system property.true
the disconnect method of the underlying
HttpURLConnection
will be called after trying to
retrieve the resource.public void setDisconnectsAfterUse(boolean disconnectAfterUse)
HttpURLConnection
after trying to retrieve the resource.
Whether the TCP socket is actually closed or reused depends on the
underlying HTTP implementation and the setting of the
keep.alive
system property.
If true
the disconnect method of the underlying
HttpURLConnection
will be called after trying to
retrieve the resource.public Proxy getProxy()
https.proxyHost
Java system
property.null
if no proxy should be used.public void setProxy(Proxy proxy)
https.proxyHost
Java system
property.proxy
- The proxy to use or null
if no proxy should be
used.public Resource retrieveResource(URL url) throws IOException
ResourceRetriever
retrieveResource
in interface ResourceRetriever
url
- The URL of the resource. Its scheme must be HTTP or
HTTPS. Must not be null
.IOException
- If the HTTP connection to the specified URL
failed or the resource couldn't be retrieved.protected HttpURLConnection openConnection(URL url) throws IOException
Proxy
if available.url
- The URL of the resource. Its scheme must be HTTP or
HTTPS. Must not be null
.IOException
- If the HTTP(S) connection to the specified URL
failed.Copyright © 2021 Connect2id Ltd.. All rights reserved.