adrian      2003/06/20 06:33:09

  Modified:    httpclient/src/test/org/apache/commons/httpclient
                        TestResponseHeaders.java
  Log:
  Test cases for the fix to bug 20938.
  
  PR: bug 20938
  
  Reviewed by:  Michael Becke and Oleg Kalnichevski
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.8       +67 -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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestResponseHeaders.java  10 Jun 2003 22:42:52 -0000      1.7
  +++ TestResponseHeaders.java  20 Jun 2003 13:33:09 -0000      1.8
  @@ -73,6 +73,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Jeff Dever</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Sutton</a>
    * @version $Id$
    */
   public class TestResponseHeaders extends TestCase {
  @@ -153,6 +154,7 @@
               "HTTP/1.1 200 OK\r\n"
               + "proxy-connection: close\r\n"
               + "proxy-connection: close\r\n"
  +            + "Content-Length: 0\r\n"
               + "\r\n";
   
           conn.addResponse(headers, "");
  @@ -169,6 +171,7 @@
               "HTTP/1.0 200 OK\r\n"
               + "proxy-connection: keep-alive\r\n"
               + "proxy-connection: keep-alive\r\n"
  +            + "Content-Length: 0\r\n"
               + "\r\n";
   
           conn.addResponse(headers, "");
  @@ -202,6 +205,7 @@
               "HTTP/1.0 200 OK\r\n"
               +"Connection: keep-alive\r\n"
               +"Connection: keep-alive\r\n"
  +            + "Content-Length: 0\r\n"
               +"\r\n";
   
           conn.addResponse(headers, "");
  @@ -210,6 +214,65 @@
           method.getResponseBodyAsString();
           
           assertTrue(conn.isOpen());
  +    }
  +    
  +    public void testNoContentLength() throws Exception {
  +        // test with connection header
  +        SimpleHttpConnection conn = new SimpleHttpConnection();
  +        String headers = 
  +            "HTTP/1.1 200 OK\r\n"
  +            + "Connection: keep-alive\r\n"
  +            + "\r\n";
  +
  +        conn.addResponse(headers, "12345");
  +        GetMethod method = new GetMethod("/");
  +        method.execute(new HttpState(), conn);
  +        method.getResponseBodyAsString();
  +        
  +        assertFalse(conn.isOpen());
  +        
  +        // test without connection header
  +        conn = new SimpleHttpConnection();
  +        headers = "HTTP/1.1 200 OK\r\n\r\n";
  +
  +        // test with connection header
  +        conn.addResponse(headers, "12345");
  +        method = new GetMethod("/");
  +        method.execute(new HttpState(), conn);
  +        method.getResponseBodyAsString();
  +        
  +        assertFalse(conn.isOpen());
  +    }
  +
  +    public void testProxyNoContentLength() throws Exception {
  +        // test with proxy-connection header
  +        SimpleHttpConnection conn = new SimpleHttpConnection();
  +        String headers =
  +            "HTTP/1.1 200 OK\r\n"
  +            + "proxy-connection: keep-alive\r\n"
  +            + "\r\n";
  +
  +        conn.addResponse(headers, "12345");
  +        conn.setProxyHost("proxy");
  +        conn.setProxyPort(1);
  +        GetMethod method = new GetMethod("/");
  +        method.execute(new HttpState(), conn);
  +        method.getResponseBodyAsString();
  +        
  +        assertFalse(conn.isOpen());
  +
  +        // test without proxy-connection header
  +        conn = new SimpleHttpConnection();
  +        headers = "HTTP/1.1 200 OK\r\n\r\n";
  +
  +        conn.addResponse(headers, "12345");
  +        conn.setProxyHost("proxy");
  +        conn.setProxyPort(1);
  +        method = new GetMethod("/");
  +        method.execute(new HttpState(), conn);
  +        method.getResponseBodyAsString();
  +        
  +        assertFalse(conn.isOpen());
       }
   
       public void testNullHeaders() throws Exception {
  
  
  

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

Reply via email to