@@ -96,10 +96,15 @@ def __urllib2Opener():
9696 conf .cj = cookielib .LWPCookieJar ()
9797 handlers .append (urllib2 .HTTPCookieProcessor (conf .cj ))
9898
99- # Use Keep-Alive (persistent HTTP connection) only if a proxy is not set
10099 # Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
101- if conf .keepAlive and not conf .proxy :
102- handlers .append (keepAliveHandler )
100+ if conf .keepAlive :
101+ if conf .proxy :
102+ warnMsg = "persistent HTTP(s) connections, Keep-Alive, has "
103+ warnMsg += "been disabled because of it's incompatibility "
104+ warnMsg += "with HTTP(s) proxy"
105+ logger .warn (warnMsg )
106+ else :
107+ handlers .append (keepAliveHandler )
103108
104109 opener = urllib2 .build_opener (* handlers )
105110 urllib2 .install_opener (opener )
@@ -289,10 +294,15 @@ def __setGoogleDorking():
289294
290295 handlers = [ proxyHandler ]
291296
292- # Use Keep-Alive (persistent HTTP connection) only if a proxy is not set
293297 # Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
294- if conf .keepAlive and not conf .proxy :
295- handlers .append (keepAliveHandler )
298+ if conf .keepAlive :
299+ if conf .proxy :
300+ warnMsg = "persistent HTTP(s) connections, Keep-Alive, has "
301+ warnMsg += "been disabled because of it's incompatibility "
302+ warnMsg += "with HTTP(s) proxy"
303+ logger .warn (warnMsg )
304+ else :
305+ handlers .append (keepAliveHandler )
296306
297307 googleObj = Google (handlers )
298308 googleObj .getCookie ()
@@ -542,9 +552,10 @@ def __setHTTPProxy():
542552
543553 global proxyHandler
544554
545- if not conf .proxy :
555+ if not conf .proxy :
546556 if conf .hostname in ('localhost' , '127.0.0.1' ) or conf .ignoreProxy :
547557 proxyHandler = urllib2 .ProxyHandler ({})
558+
548559 return
549560
550561 debugMsg = "setting the HTTP proxy to pass by all HTTP requests"
0 commit comments