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.java47
1 files changed, 42 insertions, 5 deletions
diff --git a/java/net/URLConnection.java b/java/net/URLConnection.java
index 1f78dd8e8..28142b10a 100644
--- a/java/net/URLConnection.java
+++ b/java/net/URLConnection.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package java.net;
-import gnu.classpath.NotImplementedException;
import gnu.classpath.SystemProperties;
import java.io.IOException;
@@ -173,6 +172,11 @@ public abstract class URLConnection
private static SimpleDateFormat[] dateFormats;
private static boolean dateformats_initialized;
+
+ /**
+ * The timeout period.
+ */
+ private int timeout;
/* Cached ParsePosition, used when parsing dates. */
private ParsePosition position;
@@ -212,6 +216,38 @@ public abstract class URLConnection
}
/**
+ * Returns the connection timeout speed, in milliseconds, or zero if the timeout
+ * is infinite or not set.
+ *
+ * @return The timeout.
+ *
+ * @since 1.5
+ */
+ public int getConnectTimeout()
+ {
+ return timeout;
+ }
+
+ /**
+ * Set the connection timeout speed, 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.
+ *
+ * @since 1.5
+ */
+ public void setConnectTimeout(int timeout)
+ throws IllegalArgumentException
+ {
+ if( timeout < 0 )
+ throw new IllegalArgumentException("Timeout must be 0 or positive.");
+ this.timeout = timeout;
+ }
+
+ /**
* Returns the value of the content-length header field or -1 if the value
* is not known or not present.
*
@@ -934,11 +970,12 @@ public abstract class URLConnection
* @exception IOException If an error occurs
*/
public static String guessContentTypeFromStream(InputStream is)
- throws IOException, NotImplementedException
+ throws IOException
{
- // See /etc/gnome-vfs-mime-magic or /etc/mime-magic for a reasonable
- // idea of how to handle this.
- return "application/octet-stream";
+ String result = VMURLConnection.guessContentTypeFromStream(is);
+ if (result == null)
+ return "application/octet-stream";
+ return result;
}
/**