Index: java/org/apache/commons/httpclient/HttpMethodDirector.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodDirector.java,v retrieving revision 1.22 diff -u -r1.22 HttpMethodDirector.java --- java/org/apache/commons/httpclient/HttpMethodDirector.java 18 Apr 2004 23:51:35 -0000 1.22 +++ java/org/apache/commons/httpclient/HttpMethodDirector.java 5 May 2004 21:25:29 -0000 @@ -45,6 +45,8 @@ import org.apache.commons.httpclient.auth.HttpAuthRealm; import org.apache.commons.httpclient.auth.MalformedChallengeException; import org.apache.commons.httpclient.params.HttpClientParams; +import org.apache.commons.httpclient.params.HttpConnectionParams; +import org.apache.commons.httpclient.params.HttpMethodParams; import org.apache.commons.httpclient.params.HttpParams; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -345,8 +347,17 @@ } } } - - this.conn.setSocketTimeout(this.conn.getParams().getSoTimeout()); + int timeout = 0; + // see if a timeout is given for this method + Object param = this.params.getParameter(HttpMethodParams.SO_TIMEOUT); + if (param == null) { + // if not, use the default value + param = this.conn.getParams().getParameter(HttpConnectionParams.SO_TIMEOUT); + } + if (param != null) { + timeout = ((Integer)param).intValue(); + } + this.conn.setSocketTimeout(timeout); try { method.execute(state, this.conn); Index: java/org/apache/commons/httpclient/params/HttpConnectionParams.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java,v retrieving revision 1.3 diff -u -r1.3 HttpConnectionParams.java --- java/org/apache/commons/httpclient/params/HttpConnectionParams.java 18 Apr 2004 23:51:37 -0000 1.3 +++ java/org/apache/commons/httpclient/params/HttpConnectionParams.java 5 May 2004 21:25:30 -0000 @@ -43,9 +43,10 @@ public class HttpConnectionParams extends DefaultHttpParams { /** - * Sets the socket timeout (SO_TIMEOUT) in milliseconds which is the - * timeout for waiting for data. A timeout value of zero is interpreted as an - * infinite timeout. + * Defines the default socket timeout (SO_TIMEOUT) in milliseconds which is the + * timeout for waiting for data. A timeout value of zero is interpreted as an infinite + * timeout. This value is used when no socket timeout is set in the + * {@link HttpMethodParams HTTP method parameters}. *
* This parameter expects a value of type {@link Integer}. *
@@ -123,9 +124,10 @@ } /** - * Returns the socket timeout (SO_TIMEOUT) in milliseconds which is the - * timeout for waiting for data. A timeout value of zero is interpreted as an - * infinite timeout. + * Returns the default socket timeout (SO_TIMEOUT) in milliseconds which is the + * timeout for waiting for data. A timeout value of zero is interpreted as an infinite + * timeout. This value is used when no socket timeout is set in the + * {@link HttpMethodParams HTTP method parameters}. * * @return timeout in milliseconds */ @@ -134,9 +136,10 @@ } /** - * Sets the socket timeout (SO_TIMEOUT) in milliseconds which is the - * timeout for waiting for data. A timeout value of zero is interpreted as an - * infinite timeout. + * Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the + * timeout for waiting for data. A timeout value of zero is interpreted as an infinite + * timeout. This value is used when no socket timeout is set in the + * {@link HttpMethodParams HTTP method parameters}. * * @param timeout Timeout in milliseconds */ Index: java/org/apache/commons/httpclient/params/HttpMethodParams.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java,v retrieving revision 1.11 diff -u -r1.11 HttpMethodParams.java --- java/org/apache/commons/httpclient/params/HttpMethodParams.java 18 Apr 2004 23:51:37 -0000 1.11 +++ java/org/apache/commons/httpclient/params/HttpMethodParams.java 5 May 2004 21:25:32 -0000 @@ -218,6 +218,16 @@ public static final String STATUS_LINE_GARBAGE_LIMIT = "http.protocol.status-line-garbage-limit"; /** + * Sets the socket timeout (SO_TIMEOUT) in milliseconds to be used when executing the method. + * A timeout value of zero is interpreted as an infinite timeout. + *+ * This parameter expects a value of type {@link Integer}. + *
+ * @see java.net.SocketOptions#SO_TIMEOUT + */ + public static final String SO_TIMEOUT = "http.socket.timeout"; + + /** * Creates a new collection of parameters with the collection returned * by {@link #getDefaultParams()} as a parent. The collection will defer * to its parent for a default value if a particular parameter is not @@ -363,6 +373,27 @@ setParameter(COOKIE_POLICY, policy); } + /** + * Returns the default socket timeout (SO_TIMEOUT) in milliseconds which is the + * timeout for waiting for data. A timeout value of zero is interpreted as an infinite + * timeout. + * + * @return timeout in milliseconds + */ + public int getSoTimeout() { + return getIntParameter(SO_TIMEOUT, 0); + } + + /** + * Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the + * timeout for waiting for data. A timeout value of zero is interpreted as an infinite + * timeout. + * + * @param timeout Timeout in milliseconds + */ + public void setSoTimeout(int timeout) { + setIntParameter(SO_TIMEOUT, timeout); + } private static final String[] PROTOCOL_STRICTNESS_PARAMETERS = { UNAMBIGUOUS_STATUS_LINE,