summaryrefslogtreecommitdiff
path: root/java/net/URLConnection.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/net/URLConnection.java')
-rw-r--r--java/net/URLConnection.java57
1 files changed, 50 insertions, 7 deletions
diff --git a/java/net/URLConnection.java b/java/net/URLConnection.java
index 325ff2329..674058014 100644
--- a/java/net/URLConnection.java
+++ b/java/net/URLConnection.java
@@ -175,9 +175,14 @@ public abstract class URLConnection
private static boolean dateformats_initialized;
/**
- * The timeout period.
+ * The connection timeout period.
*/
- private int timeout;
+ private int connectTimeout;
+
+ /**
+ * The read timeout period.
+ */
+ private int readTimeout;
/* Cached ParsePosition, used when parsing dates. */
private ParsePosition position;
@@ -217,8 +222,8 @@ public abstract class URLConnection
}
/**
- * Returns the connection timeout speed, in milliseconds, or zero if the timeout
- * is infinite or not set.
+ * Returns the connection timeout speed, in milliseconds, or zero if
+ * the timeout is infinite or not set.
*
* @return The timeout.
*
@@ -226,7 +231,7 @@ public abstract class URLConnection
*/
public int getConnectTimeout()
{
- return timeout;
+ return connectTimeout;
}
/**
@@ -236,7 +241,7 @@ public abstract class URLConnection
*
* Throws an <code>IllegalArgumentException</code> if timeout < 0.
*
- * @param timeout - The timeout, in milliseconds.
+ * @param timeout the timeout, in milliseconds.
*
* @since 1.5
*/
@@ -245,7 +250,45 @@ public abstract class URLConnection
{
if( timeout < 0 )
throw new IllegalArgumentException("Timeout must be 0 or positive.");
- this.timeout = timeout;
+ connectTimeout = timeout;
+ }
+
+ /**
+ * Returns the read timeout, in milliseconds, or zero if the timeout
+ * is infinite or not set.
+ *
+ * @return The timeout.
+ *
+ * @see #setReadTimeout
+ *
+ * @since 1.5
+ */
+ public int getReadTimeout()
+ {
+ return readTimeout;
+ }
+
+ /**
+ * Set the read timeout, in milliseconds, or zero if the timeout
+ * is to be considered infinite. Note that in certain socket
+ * implementations/platforms this method may not have any effect.
+ *
+ * Throws an <code>IllegalArgumentException</code> if timeout < 0.
+ *
+ * @param timeout - The timeout, in milliseconds.
+ *
+ * @throws IllegalArgumentException if timeout is negative.
+ *
+ * @see #getReadTimeout
+ *
+ * @since 1.5
+ */
+ public void setReadTimeout(int timeout)
+ throws IllegalArgumentException
+ {
+ if( timeout < 0 )
+ throw new IllegalArgumentException("Timeout must be 0 or positive.");
+ readTimeout = timeout;
}
/**