diff options
| author | Sven de Marothy <sven@physto.se> | 2006-05-12 20:59:30 +0000 |
|---|---|---|
| committer | Sven de Marothy <sven@physto.se> | 2006-05-12 20:59:30 +0000 |
| commit | 89ea044d65267280e34ccb32104977aed632ad62 (patch) | |
| tree | 721d3c5de81dce8db7945f1cb058b895699643eb /gnu/java/net/protocol | |
| parent | 09d8467b1ce616bdd0a8639e0e8eb475c4696bdb (diff) | |
| download | classpath-89ea044d65267280e34ccb32104977aed632ad62.tar.gz | |
2006-05-12 Sven de Marothy <sven@physto.se>
* gnu/java/net/protocol/http/HTTPConnection.java (get): Add timeout parameter.
* gnu/java/net/protocol/http/HTTPURLConnection.java
(setConnectTimeout): New method.
(getConnection): Add timeout parameter.
* java/net/URLConnection.java
(getConnectTimeout, setConnectTimeout): Implement.
* native/target/generic/target_generic_network.h:
Set correct socket parameters SO_SNDTIMEO and SO_RCVTIMEO.
Diffstat (limited to 'gnu/java/net/protocol')
| -rw-r--r-- | gnu/java/net/protocol/http/HTTPConnection.java | 5 | ||||
| -rw-r--r-- | gnu/java/net/protocol/http/HTTPURLConnection.java | 28 |
2 files changed, 28 insertions, 5 deletions
diff --git a/gnu/java/net/protocol/http/HTTPConnection.java b/gnu/java/net/protocol/http/HTTPConnection.java index 33d9756aa..f5e831c6a 100644 --- a/gnu/java/net/protocol/http/HTTPConnection.java +++ b/gnu/java/net/protocol/http/HTTPConnection.java @@ -466,7 +466,8 @@ public class HTTPConnection */ synchronized HTTPConnection get(String host, int port, - boolean secure) + boolean secure, + int connectionTimeout, int timeout) { String ttl = SystemProperties.getProperty("classpath.net.http.keepAliveTTL"); @@ -494,7 +495,7 @@ public class HTTPConnection } if (c == null) { - c = new HTTPConnection(host, port, secure); + c = new HTTPConnection(host, port, secure, connectionTimeout, timeout); c.setPool(this); } return c; diff --git a/gnu/java/net/protocol/http/HTTPURLConnection.java b/gnu/java/net/protocol/http/HTTPURLConnection.java index 0dce7c75b..a46d1204b 100644 --- a/gnu/java/net/protocol/http/HTTPURLConnection.java +++ b/gnu/java/net/protocol/http/HTTPURLConnection.java @@ -65,7 +65,7 @@ import javax.net.ssl.SSLSocketFactory; * @author Chris Burdess (dog@gnu.org) */ public class HTTPURLConnection - extends HttpsURLConnection + extends HttpsURLConnection implements HandshakeCompletedListener { /* @@ -346,11 +346,11 @@ public class HTTPURLConnection HTTPConnection connection; if (keepAlive) { - connection = HTTPConnection.Pool.instance.get(host, port, secure); + connection = HTTPConnection.Pool.instance.get(host, port, secure, getConnectTimeout(), 0); } else { - connection = new HTTPConnection(host, port, secure); + connection = new HTTPConnection(host, port, secure, 0, getConnectTimeout()); } return connection; } @@ -653,5 +653,27 @@ public class HTTPURLConnection handshakeEvent = event; } + /** + * Set the connection timeout speed, in milliseconds, or zero if the timeout + * is to be considered infinite. + * + * Overloaded. + * + */ + public void setConnectTimeout(int timeout) + throws IllegalArgumentException + { + super.setConnectTimeout( timeout ); + if( connection == null ) + return; + try + { + connection.getSocket().setSoTimeout( timeout ); + } + catch(IOException se) + { + // Ignore socket exceptions. + } + } } |
