()
This function creates the urllib2 OpenerDirector.
This function creates the urllib2 OpenerDirector.
This function creates the urllib2 OpenerDirector .
def _urllib2Opener():
    """
    This function creates the urllib2 OpenerDirector.
    """

    debugMsg = "creating HTTP requests opener object"
    logger.debug(debugMsg)

    handlers = [proxyHandler, authHandler, redirectHandler, rangeHandler, httpsHandler]

    if not conf.dropSetCookie:
        if not conf.loadCookies:
            conf.cj = cookielib.CookieJar()
        else:
            conf.cj = cookielib.MozillaCookieJar()
            resetCookieJar(conf.cj)

        handlers.append(urllib2.HTTPCookieProcessor(conf.cj))

    # Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
    if conf.keepAlive:
        warnMsg = "persistent HTTP(s) connections, Keep-Alive, has "
        warnMsg += "been disabled because of its incompatibility "

        if conf.proxy:
            warnMsg += "with HTTP(s) proxy"
            logger.warn(warnMsg)
        elif conf.authType:
            warnMsg += "with authentication methods"
            logger.warn(warnMsg)
        else:
            handlers.append(keepAliveHandler)

    opener = urllib2.build_opener(*handlers)
    urllib2.install_opener(opener)
def _urllib2Opener ( ) : debugMsg = "creating HTTP requests opener object" logger . debug ( debugMsg ) handlers = [ proxyHandler , authHandler , redirectHandler , rangeHandler , httpsHandler ] if not conf . dropSetCookie : if not conf . loadCookies : conf . cj = cookielib . CookieJar ( ) else : conf . cj = cookielib . MozillaCookieJar ( ) resetCookieJar ( conf . cj ) handlers . append ( urllib2 . HTTPCookieProcessor ( conf . cj ) ) # Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html if conf . keepAlive : warnMsg = "persistent HTTP(s) connections, Keep-Alive, has " warnMsg += "been disabled because of its incompatibility " if conf . proxy : warnMsg += "with HTTP(s) proxy" logger . warn ( warnMsg ) elif conf . authType : warnMsg += "with authentication methods" logger . warn ( warnMsg ) else : handlers . append ( keepAliveHandler ) opener = urllib2 . build_opener ( * handlers ) urllib2 . install_opener ( opener )