| 
27 | 27 | 
 
  | 
28 | 28 | from .Config import Config  | 
29 | 29 | from .Exceptions import ParameterError, S3SSLCertificateError  | 
30 |  | -from .Utils import getBucketFromHostname  | 
 | 30 | +from .Utils import getBucketFromHostname, deunicodise_s, unicodise_s  | 
31 | 31 | 
 
  | 
32 | 32 | 
 
  | 
33 | 33 | 
 
  | 
@@ -231,17 +231,21 @@ def __init__(self, id, hostname, ssl, cfg):  | 
231 | 231 |                 debug(u'non-proxied HTTPConnection(%s, %s)', self.hostname, self.port)  | 
232 | 232 |         else:  | 
233 | 233 |             headers = {}  | 
234 |  | -            if cfg.proxy_username and cfg.proxy_password:  | 
 | 234 | +            proxy_hostname = cfg.proxy_host  | 
 | 235 | +            if '@' in cfg.proxy_host:  | 
 | 236 | +                credential, proxy_hostname = cfg.proxy_host.split('@')  | 
 | 237 | +                # FIXME: Following line can't handle username or password including colon  | 
 | 238 | +                proxy_username, proxy_password = credential.split(':')  | 
235 | 239 |                 headers['Proxy-Authorization'] = 'Basic ' + \  | 
236 |  | -                    b64encode(('%s:%s' % (cfg.proxy_username, cfg.proxy_password)).encode('utf-8')).decode('ascii')  | 
 | 240 | +                    unicodise_s(b64encode(deunicodise_s(('%s:%s' % (proxy_username, proxy_password)))))  | 
237 | 241 |             if ssl:  | 
238 |  | -                self.c = http_connection._https_connection(cfg.proxy_host, cfg.proxy_port)  | 
 | 242 | +                self.c = http_connection._https_connection(proxy_hostname, cfg.proxy_port)  | 
239 | 243 |                 debug(u'proxied HTTPSConnection(%s, %s)', cfg.proxy_host, cfg.proxy_port)  | 
240 | 244 |                 port = self.port and self.port or 443  | 
241 | 245 |                 self.c.set_tunnel(self.hostname, port, headers)  | 
242 | 246 |                 debug(u'tunnel to %s, %s', self.hostname, port)  | 
243 | 247 |             else:  | 
244 |  | -                self.c = httplib.HTTPConnection(cfg.proxy_host, cfg.proxy_port)  | 
 | 248 | +                self.c = httplib.HTTPConnection(proxy_hostname, cfg.proxy_port)  | 
245 | 249 |                 debug(u'proxied HTTPConnection(%s, %s)', cfg.proxy_host, cfg.proxy_port)  | 
246 | 250 |                 # No tunnel here for the moment  | 
247 | 251 | 
 
  | 
 | 
0 commit comments