Index: test/org/apache/commons/httpclient/TestResponseHeaders.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestResponseHeaders.java,v retrieving revision 1.6 diff -u -r1.6 TestResponseHeaders.java --- test/org/apache/commons/httpclient/TestResponseHeaders.java 23 Jan 2003 22:48:27 -0000 1.6 +++ test/org/apache/commons/httpclient/TestResponseHeaders.java 7 Jun 2003 01:26:29 -0000 @@ -62,6 +62,8 @@ package org.apache.commons.httpclient; +import org.apache.commons.httpclient.methods.GetMethod; + import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -142,6 +144,72 @@ method.execute(state, conn); assertNotNull( "Response body is null.", method.getResponseBodyAsStream() ); + } + + public void testDuplicateProxyConnection() throws Exception { + + SimpleHttpConnection conn = new SimpleHttpConnection(); + String headers = + "HTTP/1.1 200 OK\r\n" + + "proxy-connection: close\r\n" + + "proxy-connection: close\r\n" + + "\r\n"; + + conn.addResponse(headers, ""); + conn.setProxyHost("proxy"); + conn.setProxyPort(1); + GetMethod method = new GetMethod("/"); + method.execute(new HttpState(), conn); + method.getResponseBodyAsString(); + + assertFalse(conn.isOpen()); + + conn = new SimpleHttpConnection(); + headers = + "HTTP/1.0 200 OK\r\n" + + "proxy-connection: keep-alive\r\n" + + "proxy-connection: keep-alive\r\n" + + "\r\n"; + + conn.addResponse(headers, ""); + conn.setProxyHost("proxy"); + conn.setProxyPort(1); + method = new GetMethod("/"); + method.execute(new HttpState(), conn); + method.getResponseBodyAsString(); + + assertTrue(conn.isOpen()); + } + + public void testDuplicateConnection() throws Exception { + + SimpleHttpConnection conn = new SimpleHttpConnection(); + String headers = + "HTTP/1.1 200 OK\r\n" + + "Connection: close\r\n" + + "Connection: close\r\n" + + "\r\n"; + + conn.addResponse(headers, ""); + GetMethod method = new GetMethod("/"); + method.execute(new HttpState(), conn); + method.getResponseBodyAsString(); + + assertFalse(conn.isOpen()); + + conn = new SimpleHttpConnection(); + headers = + "HTTP/1.0 200 OK\r\n" + +"Connection: keep-alive\r\n" + +"Connection: keep-alive\r\n" + +"\r\n"; + + conn.addResponse(headers, ""); + method = new GetMethod("/"); + method.execute(new HttpState(), conn); + method.getResponseBodyAsString(); + + assertTrue(conn.isOpen()); } public void testNullHeaders() throws Exception {