Class Finite
java.lang.Object
org.dmfs.httpessentials.httpurlconnection.factories.decorators.Finite
- All Implemented Interfaces:
HttpUrlConnectionFactory
A
HttpUrlConnectionFactory decorator that sets connection and socket timeouts on the connection (rather than waiting forever).-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionFinite(HttpUrlConnectionFactory decorated) AnHttpUrlConnectionFactorydecorator that sets default connection timeout and socket (read) timeout on the connections returned by the decoratedHttpUrlConnectionFactory.Finite(HttpUrlConnectionFactory decorated, int connectionTimeout, int socketTimeout) AnHttpUrlConnectionFactorydecorator that sets connection timeout and socket (read) timeout on the connections returned by the decoratedHttpUrlConnectionFactory. -
Method Summary
Modifier and TypeMethodDescriptionhttpUrlConnection(URI uri) Returns anHttpURLConnectionto the given Uri.
-
Field Details
-
DEFAULT_SOCKET_TIMEOUT
public static final int DEFAULT_SOCKET_TIMEOUT- See Also:
-
DEFAULT_CONNECTION_TIMEOUT
public static final int DEFAULT_CONNECTION_TIMEOUT- See Also:
-
-
Constructor Details
-
Finite
AnHttpUrlConnectionFactorydecorator that sets default connection timeout and socket (read) timeout on the connections returned by the decoratedHttpUrlConnectionFactory. The default connection timeout is 10000 milliseconds and the default socket timeout is 120000 milliseconds.- Parameters:
decorated- AnotherHttpUrlConnectionFactory.
-
Finite
AnHttpUrlConnectionFactorydecorator that sets connection timeout and socket (read) timeout on the connections returned by the decoratedHttpUrlConnectionFactory.- Parameters:
decorated- AnotherHttpUrlConnectionFactory.connectionTimeout- The connection timeout in milliseconds. A value<0will preserve the current setting, a value of0will set an infinite timeout.socketTimeout- The read timeout in milliseconds. A value<0will preserve the current setting, a value of0will set an infinite timeout.
-
-
Method Details
-
httpUrlConnection
Description copied from interface:HttpUrlConnectionFactoryReturns anHttpURLConnectionto the given Uri.- Specified by:
httpUrlConnectionin interfaceHttpUrlConnectionFactory- Parameters:
uri- The uri to connect to. This must be an absolute URL.- Returns:
- An
HttpURLConnection. - Throws:
IllegalArgumentException- if the given URI was not a valid absolute URL.IOException
-