[Inteproxy-commits] r142 - in trunk: . inteproxy test

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jun 12 18:09:45 CEST 2008


Author: bh
Date: 2008-06-12 18:09:45 +0200 (Thu, 12 Jun 2008)
New Revision: 142

Modified:
   trunk/ChangeLog
   trunk/inteproxy/proxycore.py
   trunk/test/test_inteproxy.py
Log:
* inteproxy/proxycore.py
(InteProxyHTTPRequestHandler.open_http_connection): Handle URLs
with query and fragment parts correctly

* test/test_inteproxy.py
(TestInteProxy.test_httpproxy_with_query_and_fragment): New test
case for URLs with query and fragment parts.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-06-12 16:01:52 UTC (rev 141)
+++ trunk/ChangeLog	2008-06-12 16:09:45 UTC (rev 142)
@@ -1,5 +1,15 @@
 2008-06-12  Bernhard Herzog  <bh at intevation.de>
 
+	* inteproxy/proxycore.py
+	(InteProxyHTTPRequestHandler.open_http_connection): Handle URLs
+	with query and fragment parts correctly
+
+	* test/test_inteproxy.py
+	(TestInteProxy.test_httpproxy_with_query_and_fragment): New test
+	case for URLs with query and fragment parts.
+
+2008-06-12  Bernhard Herzog  <bh at intevation.de>
+
 	* test/test_inteproxy.py (ServerTest.remote_contents)
 	(TestInteProxy.remote_contents)
 	(TestInteProxyWithExtraProxy.remote_contents): Move the actual

Modified: trunk/inteproxy/proxycore.py
===================================================================
--- trunk/inteproxy/proxycore.py	2008-06-12 16:01:52 UTC (rev 141)
+++ trunk/inteproxy/proxycore.py	2008-06-12 16:09:45 UTC (rev 142)
@@ -144,23 +144,26 @@
         for both.  The return value is the httplib response object.
         """
         scheme, netloc, path, query, fragment = urlparse.urlsplit(remote_url)
+        # the URI used in the request.  Usually, it's like remote_url
+        # but with schem and netloc removed.
+        request_uri = urlparse.urlunsplit(("", "", path, query, fragment))
         if scheme == "http":
             connection_class = httplib.HTTPConnection
             if self.server.http_proxy_url:
                 netloc = urlparse.urlsplit(self.server.http_proxy_url)[1]
-                path = remote_url
+                request_uri = remote_url
         elif scheme == "https":
             connection_class = httplib.HTTPSConnection
             if self.server.https_proxy_url:
                 netloc = urlparse.urlsplit(self.server.https_proxy_url)[1]
-                path = remote_url
+                request_uri = remote_url
                 connection_class = HTTPSProxyConnection
 
         connection = connection_class(netloc)
         if self.request_version == "HTTP/1.0":
             connection._http_vsn = 10
 
-        connection.putrequest(client_request.method, path,
+        connection.putrequest(client_request.method, request_uri,
                               skip_accept_encoding=True)
 
         for header, value in client_request.headers.items():

Modified: trunk/test/test_inteproxy.py
===================================================================
--- trunk/test/test_inteproxy.py	2008-06-12 16:01:52 UTC (rev 141)
+++ trunk/test/test_inteproxy.py	2008-06-12 16:09:45 UTC (rev 142)
@@ -75,9 +75,10 @@
 
     remote_contents = [
         ("/wms", [("Content-Type", "text/plain")], "wms data"),
+        ("/search?q=foo#section1", [("Content-Type", "text/plain")],
+         "some text"),
         ]
 
-
     def test_httpproxy_passthrough(self):
         http = httplib.HTTPConnection("localhost", self.server.server_port)
         http.request("GET", self.remote_server_base_url + "wms")
@@ -86,6 +87,16 @@
         data = response.read()
         self.assertEquals(data, "wms data")
 
+    def test_httpproxy_with_query_and_fragment(self):
+        http = httplib.HTTPConnection("localhost", self.server.server_port)
+        http.request("GET",
+                     self.remote_server_base_url + "search?q=foo#section1")
+        response = http.getresponse()
+        self.assertEquals(response.status, 200)
+        data = response.read()
+        self.assertEquals(data, "some text")
+
+
 class TestInteProxyWithExtraProxy(ServerTest):
 
     remote_contents = [



More information about the Inteproxy-commits mailing list