Added warning message if both --proxy and --keep-alive are provided

This commit is contained in:
Bernardo Damele 2010-06-30 11:41:42 +00:00
parent d40a238335
commit 24428c1a1b

View File

@ -96,9 +96,14 @@ 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:
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)
@ -289,9 +294,14 @@ 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:
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)
@ -545,6 +555,7 @@ def __setHTTPProxy():
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"