commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestResponseHeaders.java
Date Thu, 26 Feb 2004 20:25:56 GMT
olegk       2004/02/26 12:25:55

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpMethodBase.java
               httpclient/src/test/org/apache/commons/httpclient
                        TestResponseHeaders.java
  Log:
  PR #27237 (ArrayIndexOutOfBounds Exception on invalid content-length)
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke
  
  Revision  Changes    Path
  1.200     +5 -5      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.199
  retrieving revision 1.200
  diff -u -r1.199 -r1.200
  --- HttpMethodBase.java	22 Feb 2004 18:08:45 -0000	1.199
  +++ HttpMethodBase.java	26 Feb 2004 20:25:55 -0000	1.200
  @@ -620,7 +620,7 @@
           if (headers.length > 1) {
               LOG.warn("Multiple content-length headers detected");
           }
  -        for (int i = headers.length - 1; i >= 0; i++) {
  +        for (int i = headers.length - 1; i >= 0; i--) {
               Header header = headers[i];
               try {
                   return Long.parseLong(header.getValue());
  
  
  
  1.14      +32 -4     jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestResponseHeaders.java
  
  Index: TestResponseHeaders.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestResponseHeaders.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestResponseHeaders.java	22 Feb 2004 18:08:49 -0000	1.13
  +++ TestResponseHeaders.java	26 Feb 2004 20:25:55 -0000	1.14
  @@ -189,6 +189,34 @@
           assertFalse(conn.isOpen());
       }
   
  +    public void testInvalidContentLength1() throws Exception {
  +        // test with connection header
  +        String headers = "HTTP/1.1 200 OK\r\n"
  +            + "Content-Length: 5\r\n"
  +            + "Content-Length: stuff\r\n"
  +            + "\r\n";
  +
  +        // test with connection header
  +        conn.addResponse(headers, "12345");
  +        GetMethod method = new GetMethod("/");
  +        client.executeMethod(method);
  +        assertEquals(5, method.getResponseContentLength()); 
  +    }
  +
  +    public void testInvalidContentLength2() throws Exception {
  +        // test with connection header
  +        String headers = "HTTP/1.1 200 OK\r\n"
  +            + "Content-Length: stuff\r\n"
  +            + "Content-Length: 5\r\n"
  +            + "\r\n";
  +
  +        // test with connection header
  +        conn.addResponse(headers, "12345");
  +        GetMethod method = new GetMethod("/");
  +        client.executeMethod(method);
  +        assertEquals(5, method.getResponseContentLength()); 
  +    }
  +
       public void testProxyNoContentLength() throws Exception {
           // test with proxy-connection header
           String headers =
  
  
  

---------------------------------------------------------------------
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