Index: java/org/apache/commons/httpclient/HttpConnection.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v retrieving revision 1.99 diff -u -r1.99 HttpConnection.java --- java/org/apache/commons/httpclient/HttpConnection.java 13 Sep 2004 16:25:19 -0000 1.99 +++ java/org/apache/commons/httpclient/HttpConnection.java 14 Sep 2004 09:41:22 -0000 @@ -1,5 +1,5 @@ /* - * $Header: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v 1.99 2004/09/13 16:25:19 olegk Exp $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v 1.99 2004/09/13 16:25:19 olegk Exp $ * $Revision: 1.99 $ * $Date: 2004/09/13 16:25:19 $ * @@ -679,6 +679,12 @@ socket.setTcpNoDelay(this.params.getTcpNoDelay()); socket.setSoTimeout(this.params.getSoTimeout()); + + int linger = this.params.getLinger(); + if (linger >= 0) { + socket.setSoLinger(linger > 0, linger); + } + int sndBufSize = this.params.getSendBufferSize(); if (sndBufSize >= 0) { socket.setSendBufferSize(sndBufSize); 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.5 diff -u -r1.5 HttpConnectionParams.java --- java/org/apache/commons/httpclient/params/HttpConnectionParams.java 13 May 2004 04:01:22 -0000 1.5 +++ java/org/apache/commons/httpclient/params/HttpConnectionParams.java 14 Sep 2004 09:41:22 -0000 @@ -94,6 +94,18 @@ public static final String SO_RCVBUF = "http.socket.receivebuffer"; /** + * Sets SO_LINGER with the specified linger time in seconds. The maximum timeout + * value is platform specific. Value 0 implies that the option is disabled. + * Value -1 implies that the JRE default is used. The setting only affects + * socket close. + *

+ * This parameter expects a value of type {@link Integer}. + *

+ * @see java.net.SocketOptions#SO_LINGER + */ + public static final String SO_LINGER = "http.socket.linger"; + + /** * Determines the timeout until a connection is etablished. A value of zero * means the timeout is not used. The default value is zero. *

@@ -219,6 +231,30 @@ */ public void setReceiveBufferSize(int size) { setIntParameter(SO_RCVBUF, size); + } + + /** + * Returns linger-on-close timeout. Value 0 implies that the option is + * disabled. Value -1 implies that the JRE default is used. + * + * @return the linger-on-close timeout + */ + public int getLinger() { + return getIntParameter(SO_LINGER, -1); + } + + /** + * Returns linger-on-close timeout. This option disables/enables immediate return + * from a close() of a TCP Socket. Enabling this option with a non-zero Integer + * timeout means that a close() will block pending the transmission and + * acknowledgement of all data written to the peer, at which point the socket is + * closed gracefully. Value 0 implies that the option is + * disabled. Value -1 implies that the JRE default is used. + * + * @param value the linger-on-close timeout + */ + public void setLinger(int value) { + setIntParameter(SO_LINGER, value); } /**