commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r280648 - in /jakarta/commons/proper/httpclient/trunk/src: java/org/apache/commons/httpclient/HttpMethodBase.java test/org/apache/commons/httpclient/TestConnectionPersistence.java
Date Tue, 13 Sep 2005 20:34:23 GMT
Author: olegk
Date: Tue Sep 13 13:34:16 2005
New Revision: 280648

URL: http://svn.apache.org/viewcvs?rev=280648&view=rev
Log:
PR #36369 (Can not set the "Proxy-connection" header)

Contributed by Oleg Kalnichevski
Reviewed by Ortwin Gl├╝ck

Modified:
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestConnectionPersistence.java

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java?rev=280648&r1=280647&r2=280648&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Tue Sep 13 13:34:16 2005
@@ -1262,7 +1262,9 @@
         LOG.trace("enter HttpMethodBase.addProxyConnectionHeader("
                   + "HttpState, HttpConnection)");
         if (!conn.isTransparent()) {
-            setRequestHeader("Proxy-Connection", "Keep-Alive");
+        	if (getRequestHeader("Proxy-Connection") == null) {
+                addRequestHeader("Proxy-Connection", "Keep-Alive");
+        	}
         }
     }
 

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestConnectionPersistence.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestConnectionPersistence.java?rev=280648&r1=280647&r2=280648&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestConnectionPersistence.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestConnectionPersistence.java
Tue Sep 13 13:34:16 2005
@@ -29,10 +29,12 @@
 
 import java.io.IOException;
 
+import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.commons.httpclient.server.HttpRequestHandler;
 import org.apache.commons.httpclient.server.SimpleHttpServerConnection;
+import org.apache.commons.httpclient.server.SimpleProxy;
 import org.apache.commons.httpclient.server.SimpleRequest;
 import org.apache.commons.httpclient.server.SimpleResponse;
 
@@ -215,5 +217,36 @@
         assertFalse(connman.getConection().isOpen());
     }
 
+    public void testProxyConnClose() throws Exception {
+        this.server.setHttpService(new EchoService());
+        this.proxy = new SimpleProxy();
+        this.client.getHostConfiguration().setProxy(
+            proxy.getLocalAddress(), 
+            proxy.getLocalPort());                
+
+        AccessibleHttpConnectionManager connman = new AccessibleHttpConnectionManager();
+        
+        this.client.setHttpConnectionManager(connman);
+        
+        GetMethod httpget = new GetMethod("/test/");
+        try {
+            this.client.executeMethod(httpget);
+        } finally {
+        	httpget.releaseConnection();
+        }
+        assertTrue(connman.getConection().isOpen());
+
+        httpget = new GetMethod("/test/");
+        httpget.setRequestHeader("Proxy-Connection", "Close");
+        try {
+            this.client.executeMethod(httpget);
+        } finally {
+        	httpget.releaseConnection();
+        }
+        assertFalse(connman.getConection().isOpen());
+        assertEquals("Close", httpget.getRequestHeader("Proxy-Connection").getValue());
+    }
+
+    
 }
 



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