I've Squid (v 2.7) proxying server with some access credentials for development
purposes, also I've external proxy server Squid (v 2.6).
Testing Squid using pycurl shows that request go via my proxy server
"DESKTOP:3128" and external Proxy server whether httplib2 doesn't make sense
proxy or not.
PYCURL CODE:
{{{
import pycurl
c1 = pycurl.Curl()
c1.setopt(pycurl.URL, 'http://google.com')
c1.setopt(pycurl.PROXY, 'localhost')
c1.setopt(pycurl.PROXYPORT, 3128)
c1.setopt(pycurl.PROXYTYPE, pycurl.PROXYTYPE_HTTP)
c1.setopt(pycurl.PROXYAUTH, pycurl.HTTPAUTH_BASIC)
c1.setopt(pycurl.PROXYUSERPWD, 'user:user')
c1.setopt(pycurl.VERBOSE, 1)
c1.perform()
}}}
PYCURL RESULT:
{{{
* HTTP 1.0, assume close after body
< HTTP/1.0 301 Moved Permanently
< Location: http://www.google.com/
< Content-Type: text/html; charset=UTF-8
< Date: Fri, 27 May 2011 16:03:00 GMT
< Expires: Sun, 26 Jun 2011 16:03:00 GMT
< Cache-Control: public, max-age=2592000
< Server: gws
< Content-Length: 219
< X-XSS-Protection: 1; mode=block
< X-Cache: MISS from Proxy
< X-Cache-Lookup: HIT from Proxy:50001
< Age: 582
< X-Cache: HIT from DESKTOP
< X-Cache-Lookup: HIT from DESKTOP:3128
< Via: 1.0 Proxy:50001 (squid/2.6.STABLE18), 1.0 DESKTOP:3128
(squid/2.7.STABLE7)
* HTTP/1.0 connection set to keep alive!
< Connection: keep-alive
* HTTP/1.0 proxy connection set to keep alive!
< Proxy-Connection: keep-alive
}}}
But httplib2 doesn't make sense it gives me back the results of a direct
request even if I provide wrong parameters.
HTTPLIB2 CODE:
{{{
import httplib2
httplib2.debuglevel = 4
h1 = httplib2.Http(proxy_info = httplib2.ProxyInfo(4, 'localhost', 3128,
proxy_user = 'user', proxy_pass = 'user'))
h1.request('http://google.com')
}}}
HTTPLIB2 Result:
{{{
connect: (www.google.com, 80)
send: 'GET / HTTP/1.1\r\nHost: www.google.com\r\naccept-encoding: gzip,
deflate\r\nuser-agent: Python-httplib2/$Rev$\r\n\r\n'
reply: 'HTTP/1.0 200 OK\r\n'
header: Date: Fri, 27 May 2011 16:21:48 GMT
header: Expires: -1
header: Cache-Control: private, max-age=0
header: Content-Type: text/html; charset=ISO-8859-1
header: Set-Cookie:
PREF=ID=6c5e9f6d7f396906:FF=0:TM=1306513308:LM=1306513308:S=1engqCumc81vBLXs;
expires=Sun, 26-May-2013 16:21:48 GMT; path=/; domain=.google.com
header: Set-Cookie:
NID=47=diIFh-WXibe3GoHV08lbN-yx5AOBBx3vlqW6HqAozxXTdEifq1PQ3rPzCLa3PiHxKix-pY7TX
oqGJCcEX7h3eA45tYyRBvHZm-_M7V9QqUZNAqpxOCbCIoeuPAbgFIRa; expires=Sat,
26-Nov-2011 16:21:48 GMT; path=/; domain=.google.com; HttpOnly
header: Server: gws
header: X-XSS-Protection: 1; mode=block
header: X-Cache: MISS from Proxy
header: X-Cache-Lookup: MISS from Proxy:50001
header: Via: 1.0 Proxy:50001 (squid/2.6.STABLE18)
header: Connection: close
}}}
In the examples shown above you can see proxying doesn't work as it have to
Original issue reported on code.google.com by sultan.i...@gmail.com on 27 May 2011 at 4:30
Original issue reported on code.google.com by
sultan.i...@gmail.com
on 27 May 2011 at 4:30