olegk 2003/07/08 14:59:18 Modified: httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java Log: Adds a feature to force-close connection in abnormal circumstances. Follow up to bug fix #21378 (corrects the previous patch apllied by mistake) Contributed by Michael Becke & Oleg Kalnichevski Revision Changes Path 1.163 +16 -19 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java Index: HttpMethodBase.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v retrieving revision 1.162 retrieving revision 1.163 diff -u -r1.162 -r1.163 --- HttpMethodBase.java 8 Jul 2003 21:24:37 -0000 1.162 +++ HttpMethodBase.java 8 Jul 2003 21:59:18 -0000 1.163 @@ -258,8 +258,8 @@ /** true if we are finished with the connection */ private boolean doneWithConnection = false; - /** true if the connection must be dropped */ - private boolean forceCloseConnection = false; + /** true if the connection must be closed when no longer needed */ + private boolean connectionCloseForced = false; /** Number of milliseconds to wait for 100-contunue response. */ private static final int RESPONSE_WAIT_TIME_MS = 3000; @@ -846,29 +846,26 @@ } /** - * Return <tt>true</tt> if the connection must be dropped due to some - * abnormal circumstances, <tt>false</tt> if normal decision - * process should take place. + * Tests if the connection should be force-closed when no longer needed. * - * @return <tt>true</tt> if the connection must be dropped. + * @return <code>true</code> if the connection must be closed */ - protected boolean getForceCloseConnection() { - return this.forceCloseConnection; + protected boolean isConnectionCloseForced() { + return this.connectionCloseForced; } /** - * Set to <tt>true</tt> if the connection must be dropped due to some - * abnormal circumstances. Set to <tt>false</tt> if normal decision - * process should take place. + * Sets whether or not the connection should be force-closed when no longer + * needed. This value should only be set to <code>true</code> in abnormal + * circumstances. * - * @param b <tt>true</tt> if the connection must be dropped, <tt>false</tt> + * @param b <code>true</code> if the connection must be closed, <code>false</code> * otherwise. */ - protected void setForceCloseConnection(boolean b) { - this.forceCloseConnection = b; + protected void setConnectionCloseForced(boolean b) { + this.connectionCloseForced = b; } - /** * Return true if we should close the connection now. The connection will * only be left open if we are using HTTP1.1 or if "Connection: keep-alive" @@ -881,7 +878,7 @@ protected boolean shouldCloseConnection(HttpConnection conn) { // Connection must be closed due to an abnormal circumstance - if (getForceCloseConnection()) { + if (isConnectionCloseForced()) { LOG.debug("Should forcefully close connection."); return true; } @@ -1293,7 +1290,7 @@ recoverableExceptionCount = 0; inExecute = false; doneWithConnection = false; - forceCloseConnection = false; + connectionCloseForced = false; } /** @@ -2081,14 +2078,14 @@ } // The connection must be terminated by closing // the socket as per RFC 2616, 3.6 - setForceCloseConnection(true); + setConnectionCloseForced(true); result = is; } } else { int expectedLength = getResponseContentLength(); if (expectedLength == -1) { if (canResponseHaveBody(statusLine.getStatusCode())) { - setForceCloseConnection(true); + setConnectionCloseForced(true); result = is; } } else {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]