public class HttpResourceConnection
extends java.lang.Object
implements java.lang.AutoCloseable
| Constructor and Description |
|---|
HttpResourceConnection(Settings settings)
Constructs a new HttpResourceConnection object.
|
HttpResourceConnection(Settings settings,
boolean usesProxy)
Constructs a new HttpResourceConnection object.
|
HttpResourceConnection(Settings settings,
boolean usesProxy,
java.lang.String userKey,
java.lang.String passwordKey)
Constructs a new HttpResourceConnection object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkForCommonExceptionTypes(java.io.IOException ex)
Analyzes the IOException, logs the appropriate information for debugging
purposes, and then throws a DownloadFailedException that wraps the IO
Exception for common IO Exceptions.
|
void |
close() |
java.io.InputStream |
fetch(java.net.URL url)
Retrieves the resource identified by the given URL and returns the
InputStream.
|
boolean |
isClosed()
Returns whether or not the connection has been closed.
|
public HttpResourceConnection(Settings settings)
settings - the configured settingspublic HttpResourceConnection(Settings settings, boolean usesProxy)
settings - the configured settingsusesProxy - control whether this conn will use the defined proxy.public HttpResourceConnection(Settings settings, boolean usesProxy, java.lang.String userKey, java.lang.String passwordKey)
settings - the configured settingsusesProxy - control whether this conn will use the defined proxyuserKey - the settings key for the username to be usedpasswordKey - the settings key for the password to be usedpublic java.io.InputStream fetch(java.net.URL url)
throws DownloadFailedException,
TooManyRequestsException,
ResourceNotFoundException
url - the URL of the resource to downloadDownloadFailedException - is thrown
if there is an error downloading the resourceTooManyRequestsException - thrown when a 429 is receivedResourceNotFoundException - thrown when a 404 is receivedpublic void close()
Releases the underlying HTTP URL Connection.
close in interface java.lang.AutoCloseablepublic boolean isClosed()
public void checkForCommonExceptionTypes(java.io.IOException ex)
throws DownloadFailedException
ex - the original exceptionDownloadFailedException - a wrapper
exception that contains the original exception as the causeCopyright© 2012-21 Jeremy Long. All Rights Reserved.