Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting proxy on httplib2

Tags:

python

http

proxy

I have a trouble of connecting to a website using httplib2. My computer is behind a firewall and, as https://code.google.com/p/httplib2/wiki/Examples suggests, I did as follows:

import httplib2
from httplib2 import socks

http = httplib2.Http(proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, <proxy host address>, 8080, proxy_user = <proxy user id>, proxy_pass = <proxy password>))
resp, content = http.request("http://google.com", "GET")

But, I am still getting

httplib2.ServerNotFoundError: Unable to find the server at google.com

My computer works fine with urllib2. Can anybody help me?

like image 507
DSKim Avatar asked Mar 21 '23 19:03

DSKim


1 Answers

You can try using "PROXY_TYPE_HTTP_NO_TUNNEL" if your server requires no tunneling

import httplib2

http = httplib2.Http(proxy_info = httplib2.ProxyInfo(httplib2.socks.PROXY_TYPE_HTTP_NO_TUNNEL, 'proxy.example.com', 8080, proxy_user = 'username', proxy_pass = 'password') )
resp, content = http.request("http://google.com", "GET")

It was a known bug that was fixed due to an issue #38

like image 186
blugasmask Avatar answered Mar 31 '23 19:03

blugasmask