import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
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;
}
/**
- * 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.
*
*/
public int getConnectTimeout()
{
- return timeout;
+ return connectTimeout;
}
/**
*
* Throws an <code>IllegalArgumentException</code> if timeout < 0.
*
- * @param timeout - The timeout, in milliseconds.
+ * @param timeout the timeout, in milliseconds.
*
* @since 1.5
*/
{
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;
}
/**
*
* @since 1.4
*/
- public Map getHeaderFields()
+ public Map<String,List<String>> getHeaderFields()
{
// Subclasses for specific protocols override this.
- return Collections.EMPTY_MAP;
+ return Collections.emptyMap();
}
/**
*
* @since 1.4
*/
- public Map getRequestProperties()
+ public Map<String,List<String>> getRequestProperties()
{
if (connected)
throw new IllegalStateException("Already connected");
// Overridden by subclasses that support reading header fields from the
// request.
- return Collections.EMPTY_MAP;
+ return Collections.emptyMap();
}
/**