[Inteproxy-commits] r170 - in trunk: . inteproxy

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 25 20:40:53 CET 2008


Author: bh
Date: 2008-11-25 20:40:52 +0100 (Tue, 25 Nov 2008)
New Revision: 170

Modified:
   trunk/ChangeLog
   trunk/inteproxy/proxycore.py
Log:
* inteproxy/proxycore.py
(InteProxyHTTPRequestHandler.open_http_connection): Refactor to
reduce code duplication


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-11-25 18:54:56 UTC (rev 169)
+++ trunk/ChangeLog	2008-11-25 19:40:52 UTC (rev 170)
@@ -1,5 +1,11 @@
 2008-11-25  Bernhard Herzog  <bh at intevation.de>
 
+	* inteproxy/proxycore.py
+	(InteProxyHTTPRequestHandler.open_http_connection): Refactor to
+	reduce code duplication
+
+2008-11-25  Bernhard Herzog  <bh at intevation.de>
+
 	* inteproxy/proxycore.py (MasterWorkerServer.__init__): Rename the
 	proxy parameters and instance variables.  Their values are no
 	longer strings with urls but objects with attributes.

Modified: trunk/inteproxy/proxycore.py
===================================================================
--- trunk/inteproxy/proxycore.py	2008-11-25 18:54:56 UTC (rev 169)
+++ trunk/inteproxy/proxycore.py	2008-11-25 19:40:52 UTC (rev 170)
@@ -116,20 +116,20 @@
         # 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))
+        proxy = None
         if scheme == "http":
             connection_class = httplib.HTTPConnection
-            if self.server.http_proxy:
-                proxy = self.server.http_proxy
-                netloc = "%s:%d" % (proxy.host, proxy.port)
-                request_uri = remote_url
+            proxy = self.server.http_proxy
         elif scheme == "https":
             connection_class = httplib.HTTPSConnection
-            if self.server.https_proxy:
-                proxy = self.server.https_proxy
-                netloc = "%s:%d" % (proxy.host, proxy.port)
-                request_uri = remote_url
+            proxy = self.server.https_proxy
+            if proxy is not None:
                 connection_class = HTTPSProxyConnection
 
+        if proxy is not None:
+            netloc = "%s:%d" % (proxy.host, proxy.port)
+            request_uri = remote_url
+
         connection = connection_class(netloc)
         if self.request_version == "HTTP/1.0":
             connection._http_vsn = 10



More information about the Inteproxy-commits mailing list