Windows 7 x64, Python 2.7.6 x86_64, httplib2 0.8
If no default gateway is configured, using httplib2 via a proxy will fail with
ServerNotFoundError. With any gateway configured (no matter whether it actually
works or not), it will succeed. I guess that getaddrinfo is used to resolve the
hostname. Depending on how it is called, it will return an error if there is no
route to the host. Unfortunately I don't know any details about getaddrinfo,
how to call it correctly and whether it is actually called by httplib2.
A workaround is to use proxy_rdns=True.
I used this script based on the one from the examples page:
import httplib2
import socks
httplib2.debuglevel=4
h = httplib2.Http(proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP,
'192.168.1.123', 3128))
r,c = h.request("http://example.com")
I first ran it without a default gateway. Then I set the default gateway to a
valid LAN IP that is unused and ran it again. This is the output:
C:\Users\someuser\Desktop>python foo.py
Traceback (most recent call last):
File "foo.py", line 6, in <module>
r,c = h.request("http://example.com")
File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1570, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey
)
File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1317, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1258, in _conn_request
raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at example.com
C:\Users\someuser\Desktop>route add 0.0.0.0 mask 0.0.0.0 192.168.1.xxx #
(where xxx is unused, i.e. not a working gateway)
OK!
C:\Users\someuser\Desktop>python foo.py
connect: (example.com, 80) ************
proxy: ('192.168.1.123', 3128, None, None, None) ************
send: 'GET / HTTP/1.1\r\nHost: example.com\r\naccept-encoding: gzip,
deflate\r\nuser-agent: Python-httplib2/0.8 (gzip)\r
\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Accept-Ranges: bytes
header: Cache-Control: max-age=604800
header: Content-Type: text/html
header: Date: Fri, 10 Jan 2014 14:45:40 GMT
header: Etag: "359670651"
header: Expires: Fri, 17 Jan 2014 14:45:40 GMT
header: Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
header: Server: ECS (iad/1984)
header: X-Cache: HIT
header: x-ec-custom-error: 1
header: Content-Length: 1270
C:\Users\someuser\Desktop>
Original issue reported on code.google.com by Foobarte...@gmail.com on 10 Jan 2014 at 3:14
Original issue reported on code.google.com by
Foobarte...@gmail.com
on 10 Jan 2014 at 3:14