Skip to content

Instantly share code, notes, and snippets.

@fsouza
Created November 29, 2012 16:13
Show Gist options
  • Save fsouza/4170072 to your computer and use it in GitHub Desktop.
Save fsouza/4170072 to your computer and use it in GitHub Desktop.
diff -ru a/boto/connection.py b/boto/connection.py
--- a/boto/connection.py 2012-11-29 14:04:38.000000000 -0200
+++ b/boto/connection.py 2012-11-29 11:51:16.000000000 -0200
@@ -658,7 +658,7 @@
return self.new_http_connection(host, is_secure)
def new_http_connection(self, host, is_secure):
- if self.use_proxy:
+ if self.use_proxy and not is_secure:
host = '%s:%d' % (self.proxy, int(self.proxy_port))
if host is None:
host = self.server_name()
@@ -667,7 +667,7 @@
'establishing HTTPS connection: host=%s, kwargs=%s',
host, self.http_connection_kwargs)
if self.use_proxy:
- connection = self.proxy_ssl()
+ connection = self.proxy_ssl(host, is_secure and 443 or 80)
elif self.https_connection_factory:
connection = self.https_connection_factory(host)
elif self.https_validate_certificates and HAVE_HTTPS_CONNECTION:
@@ -703,8 +703,11 @@
def put_http_connection(self, host, is_secure, connection):
self._pool.put_http_connection(host, is_secure, connection)
- def proxy_ssl(self):
- host = '%s:%d' % (self.host, self.port)
+ def proxy_ssl(self, host=None, port=None):
+ if host and port:
+ host = '%s:%d' % (host, port)
+ else:
+ host = '%s:%d' % (self.host, self.port)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.connect((self.proxy, int(self.proxy_port)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment