launchpad proxy support

Gordon Tyler gordon at doxxx.net
Fri Oct 30 00:32:14 GMT 2009


On 10/29/2009 6:25 PM, Vincent Ladeuil wrote:
>      Gordon>  I've just recently pushed another change to
>      Gordon>  lp:~doxxx/bzr/lp_proxy to fix the underlying problem in the way
>      Gordon>  urllib2 handles proxying connections to ports other than 80
>      Gordon>  (i.e. https' 443). I had to apply a workaround/hack to
>      Gordon>  _urllib2_wrappers' Request and _ConnectRequest so that they could
>      Gordon>  remember the original URL's port and supply that in the CONNECT
>      Gordon>  request to the proxy.
>
> +        # Use scheme default if no port specified in URL
> +        if not self.proxied_port:
> +            if self.get_type() == 'http':
> +                self.proxied_port = httplib.HTTPConnection.default_port
> +            elif self.get_type() == 'https':
> +                self.proxied_port = httplib.HTTPSConnection.default_port
>
> That is the controversial part. That code will not be needed if
> you define two classes instead of one, each using the right
> HTTP[S]Connection attribute.

I'm having difficulty separating this into two code paths. This snippet 
of code is "fixing" a fundamental flaw in the way urllib2 handles 
proxied requests to ports other than 80. I can't see any other way of 
doing it that isn't horribly roundabout and obtuse.

Any suggestions?

Thanks,
Gordon



More information about the bazaar mailing list