Proxy doesn't work if my local DNS server doesn't know hostname. For example, I need connect to http://api.intranet.dev/mailapi.php. However, intranet.dev is fake domain, it's doesn't exist in DNS, so I have to use proxy server 192.168.1.50:8000:
import httplib2 proxy_info = httplib2.ProxyInfo( proxy_type = httplib2.socks.PROXY_TYPE_HTTP, proxy_host = '192.168.1.50', proxy_port = 8000, proxy_rdns = True ) h = httplib2.Http(proxy_info = proxy_info) r, c = h.request('http://api.intranet.dev/mailapi.php')
It doesn't work:
ServerNotFoundError: Unable to find the server at api.intranet.dev
Problem is in the HTTPConnectionWithTimeout.connect(). There is:
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
In my example socket.getaddrinfo can't reverse self.host. There is patch which solve this problem. However, only in python2 subtree, because I haven't used Python 3.
- proxy.patch 2.52KB
Comment #1
Posted on Jun 13, 2011 by Massive Hipposocks.py has been updated to latest.
Comment #2
Posted on Jun 13, 2011 by Massive Hipposocks.py has been updated to latest.
Comment #3
Posted on Nov 21, 2011 by Swift DogIt doesn't look like this patch has been applied? Has it been fixed in some other way?
Comment #4
Posted on Apr 26, 2012 by Happy LionHi it seems the patch is not applied in HttpLib2-0.7.4-py2.7. I make it working applying manually the content of proxy.patch provided in the first post to the current version of HttpLib2.
- __init_.py.patch 1.63KB
Status: Fixed
Labels:
Type-Defect
Priority-Medium