Add support for authenticated proxies#1129
Conversation
|
Thank you for your contribution!
|
|
@fviard Thank you for your advice. For backward-compatibility, |
| # python 3 support | ||
| from urlparse import urlparse | ||
| except ImportError: | ||
| from urllib.parse import urlparse |
There was a problem hiding this comment.
It is a detail, but you can probably exchange the imports and have the python3 "from urlib.parse import urlparse" case first as it should now be the default case.
| headers = {} | ||
| proxy_hostname = cfg.proxy_host | ||
| if '@' in cfg.proxy_host: | ||
| credential, proxy_hostname = cfg.proxy_host.split('@') |
There was a problem hiding this comment.
it is probably better to use split('@', 1) to avoid unexpected issues.
| if '@' in cfg.proxy_host: | ||
| credential, proxy_hostname = cfg.proxy_host.split('@') | ||
| # FIXME: Following line can't handle username or password including colon | ||
| proxy_username, proxy_password = credential.split(':') |
There was a problem hiding this comment.
Same a previous, split(':', 1)
|
Thank your for your update and sorry for the long delay of my reply, sadly it was a very busy month :-s
Your point makes sense, but I'm a little bit reluctant to add a new option because of the confusion that it would induce. But something that could be done, I think, is to already accept url with that pattern in proxy_host. |
This PR allows s3cmd to use an authenticated proxy server.
fix #1128
Changed behavior
proxy_hostaccepts username and password (e.g.,proxy_host = username:password@hostname)s3cmd --configurecan handle a credential from environment variablehttp_proxyorhttps_proxy(ifuse_https = True)TODO
use_https = True-> SetProxy-Authenticateheader via HTTPConnection.set_tunnel()use_https = False-> Need helpsplit()withurlparse()https://github.com/s3tools/s3cmd/pull/1129/files#diff-a33e8f45f499529c23e3ee67788fb744R237-R238