New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proxy with authentication #154
Comments
@menta78 can't reproduce here. Please, show |
$ python -V file bug.py: traceback: |
If the proxy server does not require authentication the code works fine |
Thanks, it didn't reproduce because failing line is not in httplib2 source. But the problem is very clear now. |
Could you also share where this Something like |
Nevermind, I found it's pysocks. |
Please check if it works and I wasn't too fast to merge it? |
now it works for me. Many thanks! |
Released as v0.16.0 |
At office we have a proxy server with authentication. The environment variables HTTP_PROXY and HTTPS_PROXY have value http://username:password@serveraddress:port .
Using version 0.15.0 of httplib2 (installed from conda-forge) the following code:
http = httplib2.Http()
http.request('http://www.google.com')
results in an AttributeError: 'bytes' object has no attribute 'encode'.
That's because httplib2 encodes the username and password after loading them from the environment variable, and passes them encoded to sock (line 1170 of file
__init__.py
that I'm using, at line 1174 of the latest commit a8716b1). And then socks tries to re-encode them.This code works for me:
proxy_info = httplib2.proxy_info_from_environment()
proxy_info.proxy_user = proxy_info.proxy_user.decode()
proxy_info.proxy_pass = proxy_info.proxy_pass.decode()
http = httplib2.Http(proxy_info=proxy_info)
http.request('http://www.google.com')
So, I would suggest either to not encoding these variables in proxy_info_from_environment(), or to decode them before passing them to socks
The text was updated successfully, but these errors were encountered: