remm        01/07/16 11:14:15

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpClient.java
  Log:
  - Cleanup of the response line parsing algorithm.
  - Ignore if no status test is submitted.
  - Patch submitted by Juergen Pill.
  
  Revision  Changes    Path
  1.17      +18 -23    
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java
  
  Index: HttpClient.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- HttpClient.java   2001/06/20 16:00:31     1.16
  +++ HttpClient.java   2001/07/16 18:14:14     1.17
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
 1.16 2001/06/20 16:00:31 remm Exp $
  - * $Revision: 1.16 $
  - * $Date: 2001/06/20 16:00:31 $
  + * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
 1.17 2001/07/16 18:14:14 remm Exp $
  + * $Revision: 1.17 $
  + * $Date: 2001/07/16 18:14:14 $
    *
    * ====================================================================
    *
  @@ -1002,41 +1002,36 @@
               throw new HttpException
                   ("Error in parsing the response: " + statusLine);
   
  -        int at = statusLine.indexOf(" ");
  -        if (at < 0)
  -            throw new HttpException
  -                ("Error in parsing the response: " + statusLine);
  -
  -        String protocol = statusLine.substring(0, at);
  -        if ((!protocol.equals("HTTP/1.1") && !protocol.equals("HTTP/1.0")))
  +        if ((!statusLine.startsWith("HTTP/1.1") &&
  +             !statusLine.startsWith("HTTP/1.0")))
               throw new HttpException
  -                ("Incorrect server protocol : " + protocol);
  +                ("Incorrect server protocol :" + statusLine);
   
  -        if (protocol.equals("HTTP/1.1")) {
  -            http11 = true;
  -        } else {
  -            http11 = false;
  -        }
  +        http11 = statusLine.startsWith("HTTP/1.1");
   
           int statusCode = -1;
   
  +        int at = statusLine.indexOf(" ");
  +        if (at < 0)
  +            throw new HttpException
  +                ("Error in parsing the response: " + statusLine);
  +
           int to = statusLine.indexOf(" ", at + 1);
           if (to < 0)
  -            throw new HttpException
  -                ("Status not specified: " + statusLine);
  +            to = statusLine.length();
  +
           try {
  -            statusCode = Integer.parseInt(statusLine.substring(at+1, to));
  +            statusCode = Integer.parseInt(statusLine.substring(at + 1, to));
           } catch (NumberFormatException e) {
  -            throw new HttpException
  -                ("Status not specified: " + statusLine);
  +            throw new HttpException("Status not specified: " + statusLine);
           }
   
           method.setStatusCode(statusCode);
   
  -
           String statusText = null;
           try {
  -            statusText = statusLine.substring(to + 1);
  +            if (to < statusLine.length())
  +                statusText = statusLine.substring(to + 1);
           } catch (StringIndexOutOfBoundsException e) {
               throw new HttpException
                   ("Status not specified: " + statusLine);
  
  
  

Reply via email to