mbecke      2003/03/31 16:25:24

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpMethodBase.java StatusLine.java
  Log:
  Adds support for unusual HTTP status line returned by some servers.
  
  PR: 18439
  Reviewed by: Jeff Dever and Oleg Kalnichevski
  
  Revision  Changes    Path
  1.127     +12 -6     
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.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- HttpMethodBase.java       27 Mar 2003 20:58:27 -0000      1.126
  +++ HttpMethodBase.java       1 Apr 2003 00:25:24 -0000       1.127
  @@ -2000,7 +2000,10 @@
   
           //read out the HTTP status string
           String statusString = conn.readLine();
  -        while ((statusString != null) && !statusString.startsWith("HTTP/")) {
  +        while ((statusString != null) && !statusString.startsWith("HTTP")) {
  +            if (Wire.enabled()) {
  +                Wire.input(statusString + "\r\n");
  +            }
               statusString = conn.readLine();
           }
           if (statusString == null) {
  @@ -2008,7 +2011,7 @@
               // response.  Try again.
               throw new HttpRecoverableException("Error in parsing the status "
                   + " line from the response: unable to find line starting with"
  -                + " \"HTTP/\"");
  +                + " \"HTTP\"");
           }
           if (Wire.enabled()) {
               Wire.input(statusString + "\r\n");
  @@ -2022,6 +2025,9 @@
               http11 = false;
           } else if (httpVersion.equals("HTTP/1.1")) {
               http11 = true;
  +        } else if (httpVersion.equals("HTTP")) {
  +            // some servers do not specify the version correctly, we will just 
assume 1.0
  +            http11 = false;
           } else {
               throw new HttpException("Unrecognized server protocol: '"
                                       + httpVersion + "'");
  
  
  
  1.9       +6 -6      
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/StatusLine.java
  
  Index: StatusLine.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/StatusLine.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StatusLine.java   30 Jan 2003 05:01:54 -0000      1.8
  +++ StatusLine.java   1 Apr 2003 00:25:24 -0000       1.9
  @@ -121,9 +121,9 @@
   
   
           //check validity of the Status-Line
  -        if (!statusLine.startsWith("HTTP/")) {
  +        if (!statusLine.startsWith("HTTP")) {
               throw new HttpException("Status-Line '" + statusLine 
  -                + "' does not start with HTTP/");
  +                + "' does not start with HTTP");
           }
   
           //handle the HTTP-Version
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to