commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r160331 - jakarta/commons/proper/httpclient/branches/HTTPCLIENT_2_0_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Date Wed, 06 Apr 2005 21:38:48 GMT
Author: olegk
Date: Wed Apr  6 14:38:48 2005
New Revision: 160331

URL: http://svn.apache.org/viewcvs?view=rev&rev=160331
Log:
PR #34262 (304 response status handling)

Changelog:
* Fixed broken handling of responses that may not include an entity body

Contributed by Oleg Kalnichevski
Reviewed by Michael Becke  and Ortwin Gl├╝ck

Modified:
    jakarta/commons/proper/httpclient/branches/HTTPCLIENT_2_0_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java

Modified: jakarta/commons/proper/httpclient/branches/HTTPCLIENT_2_0_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/branches/HTTPCLIENT_2_0_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java?view=diff&r1=160330&r2=160331
==============================================================================
--- jakarta/commons/proper/httpclient/branches/HTTPCLIENT_2_0_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java
(original)
+++ jakarta/commons/proper/httpclient/branches/HTTPCLIENT_2_0_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Wed Apr  6 14:38:48 2005
@@ -1,7 +1,7 @@
 /*
  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
1.159.2.33 2004/10/10 00:00:35 mbecke Exp $
  * $Revision: 1.159.2.33 $
- * $Date: 2004/10/10 00:00:35 $
+ * $Date$
  *
  * ====================================================================
  *
@@ -106,7 +106,7 @@
  * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
  * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
  *
- * @version $Revision: 1.159.2.33 $ $Date: 2004/10/10 00:00:35 $
+ * @version $Revision: 1.159.2.33 $ $Date$
  */
 public abstract class HttpMethodBase implements HttpMethod {
 
@@ -2075,22 +2075,25 @@
         } else {
             int expectedLength = getResponseContentLength();
             if (expectedLength == -1) {
-                if (canResponseHaveBody(statusLine.getStatusCode())) {
-                    Header connectionHeader = responseHeaders.getFirstHeader("Connection");
-                    String connectionDirective = null;
-                    if (connectionHeader != null) {
-                        connectionDirective = connectionHeader.getValue();
-                    }
-                    if (isHttp11() && !"close".equalsIgnoreCase(connectionDirective))
{
-                        LOG.info("Response content length is not known");
-                        setConnectionCloseForced(true);
-                    }
-                    result = is;            
+                Header connectionHeader = responseHeaders.getFirstHeader("Connection");
+                String connectionDirective = null;
+                if (connectionHeader != null) {
+                    connectionDirective = connectionHeader.getValue();
+                }
+                if (isHttp11() && !"close".equalsIgnoreCase(connectionDirective))
{
+                    LOG.info("Response content length is not known");
+                    setConnectionCloseForced(true);
                 }
+                result = is;            
             } else {
                 result = new ContentLengthInputStream(is, expectedLength);
             }
         } 
+
+        // See if the response is supposed to have a response body
+        if (!canResponseHaveBody(statusLine.getStatusCode())) {
+            result = null;
+        }
         // if there is a result - ALWAYS wrap it in an observer which will
         // close the underlying stream as soon as it is consumed, and notify
         // the watcher that the stream has been consumed.



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message