commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbe...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpConnection.java
Date Wed, 10 Sep 2003 21:37:48 GMT
mbecke      2003/09/10 14:37:48

  Modified:    httpclient/src/java/org/apache/commons/httpclient/methods
                        HeadMethod.java
               httpclient/src/java/org/apache/commons/httpclient
                        HttpConnection.java
  Log:
  Makes HttpConnection.isResponseAvailable() a little more robust, particularly when used
by HeadMethod.
  PR: 22968
  Submitted by: Michael Becke
  Reviewed by: Oleg Kalnichevski
  
  Revision  Changes    Path
  1.24      +15 -6     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/HeadMethod.java
  
  Index: HeadMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/HeadMethod.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- HeadMethod.java	9 Aug 2003 19:37:58 -0000	1.23
  +++ HeadMethod.java	10 Sep 2003 21:37:48 -0000	1.24
  @@ -68,8 +68,8 @@
   import org.apache.commons.httpclient.HttpConnection;
   import org.apache.commons.httpclient.HttpException;
   import org.apache.commons.httpclient.HttpMethodBase;
  -import org.apache.commons.httpclient.ProtocolException;
   import org.apache.commons.httpclient.HttpState;
  +import org.apache.commons.httpclient.ProtocolException;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -188,7 +188,16 @@
                   LOG.debug("Check for non-compliant response body. Timeout in " 
                    + this.bodyCheckTimeout + " ms");    
               }
  -            if (conn.isResponseAvailable(this.bodyCheckTimeout)) {
  +            boolean responseAvailable = false;
  +            try {
  +                responseAvailable = conn.isResponseAvailable(this.bodyCheckTimeout);
  +            } catch (IOException e) {
  +                LOG.debug("An IOException occurred while testing if a response was available,"
  +                    + " we will assume one is not.", 
  +                    e);
  +                responseAvailable = false;
  +            }
  +            if (responseAvailable) {
                   if (isStrictMode()) {
                       throw new ProtocolException(
                           "Body content may not be sent in response to HTTP HEAD request");
  
  
  
  1.75      +12 -5     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java
  
  Index: HttpConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- HttpConnection.java	8 Sep 2003 00:37:29 -0000	1.74
  +++ HttpConnection.java	10 Sep 2003 21:37:48 -0000	1.75
  @@ -804,7 +804,14 @@
                       LOG.debug("Input data not available after " + timeout + " ms");
                   }
               } finally {
  -                socket.setSoTimeout(soTimeout);
  +                try {
  +                    socket.setSoTimeout(soTimeout);
  +                } catch (IOException ioe) {
  +                    LOG.debug("An error ocurred while resetting soTimeout, we will assume
that"
  +                        + " no response is available.",
  +                        ioe);
  +                    result = false;
  +                }
               }
           }
           return result;
  
  
  

Mime
View raw message