Index: HttpMethodBase.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.161
diff -u -r1.161 HttpMethodBase.java
--- HttpMethodBase.java 8 Jul 2003 11:51:45 -0000 1.161
+++ HttpMethodBase.java 8 Jul 2003 11:59:25 -0000
@@ -258,6 +258,9 @@
/** true if we are finished with the connection */
private boolean doneWithConnection = false;
+ /** true if the connection must be dropped */
+ private boolean forceCloseConnection = false;
+
/** Number of milliseconds to wait for 100-contunue response. */
private static final int RESPONSE_WAIT_TIME_MS = 3000;
@@ -843,6 +846,30 @@
}
/**
+ * Return true if the connection must be dropped due to some
+ * abnormal circumstances, false if normal decision
+ * process should take place.
+ *
+ * @return true if the connection must be dropped.
+ */
+ protected boolean getForceCloseConnection() {
+ return this.forceCloseConnection;
+ }
+
+ /**
+ * Set to true if the connection must be dropped due to some
+ * abnormal circumstances. Set to false if normal decision
+ * process should take place.
+ *
+ * @param b true if the connection must be dropped, false
+ * otherwise.
+ */
+ protected void setForceCloseConnection(boolean b) {
+ this.forceCloseConnection = 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"
* was sent.
@@ -853,6 +880,12 @@
*/
protected boolean shouldCloseConnection(HttpConnection conn) {
+ // Connection must be closed due to an abnormal circumstance
+ if (getForceCloseConnection()) {
+ LOG.debug("Should forcefully close connection.");
+ return true;
+ }
+
// if we are not chunked and there is no content length the connection
// cannot be reused
if (responseHeaders.getFirstHeader("Transfer-Encoding") == null
@@ -1268,6 +1301,7 @@
recoverableExceptionCount = 0;
inExecute = false;
doneWithConnection = false;
+ forceCloseConnection = false;
}
/**
@@ -2053,8 +2087,9 @@
LOG.warn("Transfer-Encoding is set but does not contain \"chunked\": "
+ getResponseHeader("Transfer-Encoding"));
}
- // we assume that the response connection will be terminated by closing
+ // The connection must be terminated by closing
// the socket as per RFC 2616, 3.6
+ setForceCloseConnection(true);
result = is;
}
} else {