Rev 4781: Specify the port to CONNECT to for http[s] proxies. in file:///home/vila/src/bzr/bugs/186920-lp-proxy/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Oct 30 18:02:08 GMT 2009


At file:///home/vila/src/bzr/bugs/186920-lp-proxy/

------------------------------------------------------------
revno: 4781
revision-id: v.ladeuil+lp at free.fr-20091030180208-t5utkcy3elich3zo
parent: v.ladeuil+lp at free.fr-20091030154157-g43t2go85qpmhcv0
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 186920-lp-proxy
timestamp: Fri 2009-10-30 19:02:08 +0100
message:
  Specify the port to CONNECT to for http[s] proxies.
  
  * bzrlib/transport/http/_urllib2_wrappers.py:
  (Request.set_proxy): Some proxies connect to the wrong port if not
  explictly given the right port in the CONNECT request.
-------------- next part --------------
=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
--- a/bzrlib/transport/http/_urllib2_wrappers.py	2009-10-30 09:34:50 +0000
+++ b/bzrlib/transport/http/_urllib2_wrappers.py	2009-10-30 18:02:08 +0000
@@ -366,7 +366,17 @@
 
     def set_proxy(self, proxy, type):
         """Set the proxy and remember the proxied host."""
-        self.proxied_host = self.get_host()
+        if self.port is None:
+            # We need to set the default port ourselves way before it gets set
+            # by the HTTPConnection build time.
+            if self.type == 'https':
+                conn_class = HTTPSConnection
+            else:
+                conn_class = HTTPConnection
+            port = conn_class.default_port
+        else:
+            port = self.port
+        self.proxied_host = '%s:%s' % (self.get_host(), port)
         urllib2.Request.set_proxy(self, proxy, type)
 
 



More information about the bazaar-commits mailing list