public final class Finite extends java.lang.Object implements HttpUrlConnectionFactory
HttpUrlConnectionFactory decorator that sets connection and socket timeouts on the connection (rather than waiting forever).| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CONNECTION_TIMEOUT |
static int |
DEFAULT_SOCKET_TIMEOUT |
| Constructor and Description |
|---|
Finite(HttpUrlConnectionFactory decorated)
An
HttpUrlConnectionFactory decorator that sets default connection timeout and socket (read) timeout on the connections returned by the decorated
HttpUrlConnectionFactory. |
Finite(HttpUrlConnectionFactory decorated,
int connectionTimeout,
int socketTimeout)
An
HttpUrlConnectionFactory decorator that sets connection timeout and socket (read) timeout on the connections returned by the decorated
HttpUrlConnectionFactory. |
| Modifier and Type | Method and Description |
|---|---|
java.net.HttpURLConnection |
httpUrlConnection(java.net.URI uri)
Returns an
HttpURLConnection to the given Uri. |
public static final int DEFAULT_SOCKET_TIMEOUT
public static final int DEFAULT_CONNECTION_TIMEOUT
public Finite(HttpUrlConnectionFactory decorated)
HttpUrlConnectionFactory decorator that sets default connection timeout and socket (read) timeout on the connections returned by the decorated
HttpUrlConnectionFactory. The default connection timeout is 10000 milliseconds and the default socket timeout is
120000 milliseconds.decorated - Another HttpUrlConnectionFactory.public Finite(HttpUrlConnectionFactory decorated, int connectionTimeout, int socketTimeout)
HttpUrlConnectionFactory decorator that sets connection timeout and socket (read) timeout on the connections returned by the decorated
HttpUrlConnectionFactory.decorated - Another HttpUrlConnectionFactory.connectionTimeout - The connection timeout in milliseconds. A value <0 will preserve the current setting, a value of 0 will set an infinite
timeout.socketTimeout - The read timeout in milliseconds. A value <0 will preserve the current setting, a value of 0 will set an infinite timeout.public java.net.HttpURLConnection httpUrlConnection(java.net.URI uri)
throws java.lang.IllegalArgumentException,
java.io.IOException
HttpUrlConnectionFactoryHttpURLConnection to the given Uri.httpUrlConnection in interface HttpUrlConnectionFactoryuri - The uri to connect to. This must be an absolute URL.HttpURLConnection.java.lang.IllegalArgumentException - if the given URI was not a valid absolute URL.java.io.IOException