From 24428c1a1b8a3c7b157538aa2480330eb6da7e78 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Wed, 30 Jun 2010 11:41:42 +0000 Subject: [PATCH] Added warning message if both --proxy and --keep-alive are provided --- lib/core/option.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index 424c0019b..32bf2d690 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -96,10 +96,15 @@ def __urllib2Opener(): conf.cj = cookielib.LWPCookieJar() handlers.append(urllib2.HTTPCookieProcessor(conf.cj)) - # Use Keep-Alive (persistent HTTP connection) only if a proxy is not set # Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html - if conf.keepAlive and not conf.proxy: - handlers.append(keepAliveHandler) + if conf.keepAlive: + if conf.proxy: + warnMsg = "persistent HTTP(s) connections, Keep-Alive, has " + warnMsg += "been disabled because of it's incompatibility " + warnMsg += "with HTTP(s) proxy" + logger.warn(warnMsg) + else: + handlers.append(keepAliveHandler) opener = urllib2.build_opener(*handlers) urllib2.install_opener(opener) @@ -289,10 +294,15 @@ def __setGoogleDorking(): handlers = [ proxyHandler ] - # Use Keep-Alive (persistent HTTP connection) only if a proxy is not set # Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html - if conf.keepAlive and not conf.proxy: - handlers.append(keepAliveHandler) + if conf.keepAlive: + if conf.proxy: + warnMsg = "persistent HTTP(s) connections, Keep-Alive, has " + warnMsg += "been disabled because of it's incompatibility " + warnMsg += "with HTTP(s) proxy" + logger.warn(warnMsg) + else: + handlers.append(keepAliveHandler) googleObj = Google(handlers) googleObj.getCookie() @@ -542,9 +552,10 @@ def __setHTTPProxy(): global proxyHandler - if not conf.proxy: + if not conf.proxy: if conf.hostname in ('localhost', '127.0.0.1') or conf.ignoreProxy: proxyHandler = urllib2.ProxyHandler({}) + return debugMsg = "setting the HTTP proxy to pass by all HTTP requests"