'Returns an OpenerDirector that supports cookies and ignores redirects.
Returns:
A urllib2.OpenerDirector object.'

def _GetOpener(self):

    opener = urllib2.OpenerDirector()
    opener.add_handler(fancy_urllib.FancyProxyHandler())
    opener.add_handler(urllib2.UnknownHandler())
    opener.add_handler(urllib2.HTTPHandler())
    opener.add_handler(urllib2.HTTPDefaultErrorHandler())
    opener.add_handler(fancy_urllib.FancyHTTPSHandler())
    opener.add_handler(urllib2.HTTPErrorProcessor())
    opener.add_handler(ContentEncodingHandler())
    if self.save_cookies:
        self.cookie_jar.filename = os.path.expanduser(HttpRpcServer.DEFAULT_COOKIE_FILE_PATH)
        if os.path.exists(self.cookie_jar.filename):
            try:
                self.cookie_jar.load()
                self.authenticated = True
                logger.debug('Loaded    authentication    cookies    from    %s', self.cookie_jar.filename)
            except (OSError, IOError, cookielib.LoadError) as e:
                logger.debug('Could    not    load    authentication    cookies;    %s:    %s', e.__class__.__name__, e)
                self.cookie_jar.filename = None
        else:
            try:
                fd = os.open(self.cookie_jar.filename, os.O_CREAT, 384)
                os.close(fd)
            except (OSError, IOError) as e:
                logger.debug('Could    not    create    authentication    cookies    file;    %s:    %s', e.__class__.__name__, e)
                self.cookie_jar.filename = None
    opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar))
    return opener
