summaryrefslogtreecommitdiff
path: root/boto/connection.py
diff options
context:
space:
mode:
Diffstat (limited to 'boto/connection.py')
-rw-r--r--boto/connection.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/boto/connection.py b/boto/connection.py
index fc8c23b6..6d06ca18 100644
--- a/boto/connection.py
+++ b/boto/connection.py
@@ -44,7 +44,6 @@ Handles basic connections to AWS
"""
from __future__ import with_statement
-import base64
from datetime import datetime
import errno
import os
@@ -64,7 +63,7 @@ import boto.handler
import boto.cacerts
from boto import config, UserAgent
-from boto.compat import six, http_client, urlparse, quote
+from boto.compat import six, http_client, urlparse, quote, encodebytes
from boto.exception import AWSConnectionError
from boto.exception import BotoClientError
from boto.exception import BotoServerError
@@ -787,13 +786,13 @@ class AWSAuthConnection(object):
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)))
- if "timeout" in self.http_connection_kwargs:
- sock.settimeout(self.http_connection_kwargs["timeout"])
- except:
- raise
+ # Seems properly to use timeout for connect too
+ timeout = self.http_connection_kwargs.get("timeout")
+ if timeout is not None:
+ sock = socket.create_connection((self.proxy,
+ int(self.proxy_port)), timeout)
+ else:
+ sock = socket.create_connection((self.proxy, int(self.proxy_port)))
boto.log.debug("Proxy connection: CONNECT %s HTTP/1.0\r\n", host)
sock.sendall("CONNECT %s HTTP/1.0\r\n" % host)
sock.sendall("User-Agent: %s\r\n" % UserAgent)
@@ -857,7 +856,7 @@ class AWSAuthConnection(object):
return path
def get_proxy_auth_header(self):
- auth = base64.encodestring(self.proxy_user + ':' + self.proxy_pass)
+ auth = encodebytes(self.proxy_user + ':' + self.proxy_pass)
return {'Proxy-Authorization': 'Basic %s' % auth}
def set_host_header(self, request):