insights/client/connection.py
def _init_session(self):
        """
        Set up the session, auth is handled here
        """
        session = requests.Session()
        session.headers = {'User-Agent': self.user_agent,
                           'Accept': 'application/json'}
        if self.systemid is not None:
            session.headers.update({'systemid': self.systemid})
        if self.authmethod == "BASIC":
            session.auth = (self.username, self.password)
        elif self.authmethod == "CERT":
            cert = rhsmCertificate.certpath()
            key = rhsmCertificate.keypath()
            if rhsmCertificate.exists():
                session.cert = (cert, key)
            else:
                logger.error('ERROR: Certificates not found.')
        session.verify = self.cert_verify
        session.proxies = self.proxies
        session.trust_env = False
        if self.proxy_auth:
            # HACKY
            try:
                # Need to make a request that will fail to get proxies set up
                net_logger.info("GET %s", self.base_url)
                session.request(
                    "GET", self.base_url, timeout=self.config.http_timeout)
            except requests.ConnectionError:
                pass
            # Major hack, requests/urllib3 does not make access to
            # proxy_headers easy
            proxy_mgr = session.adapters['https://'].proxy_manager[self.proxies['https']]
            auth_map = {'Proxy-Authorization': self.proxy_auth}
            proxy_mgr.proxy_headers = auth_map
            proxy_mgr.connection_pool_kw['_proxy_headers'] = auth_map
            conns = proxy_mgr.pools._container
            for conn in conns:
                connection = conns[conn]
                connection.proxy_headers = auth_map
        return session

        Set up the session, auth is handled here
        
Set up the session, auth is handled here
Set up the session auth is handled here
def _init_session(self):
        session = requests.Session()
        session.headers = {'User-Agent': self.user_agent,
                           'Accept': 'application/json'}
        if self.systemid is not None:
            session.headers.update({'systemid': self.systemid})
        if self.authmethod == "BASIC":
            session.auth = (self.username, self.password)
        elif self.authmethod == "CERT":
            cert = rhsmCertificate.certpath()
            key = rhsmCertificate.keypath()
            if rhsmCertificate.exists():
                session.cert = (cert, key)
            else:
                logger.error('ERROR: Certificates not found.')
        session.verify = self.cert_verify
        session.proxies = self.proxies
        session.trust_env = False
        if self.proxy_auth:
            try:
                net_logger.info("GET %s", self.base_url)
                session.request(
                    "GET", self.base_url, timeout=self.config.http_timeout)
            except requests.ConnectionError:
                pass
            proxy_mgr = session.adapters['https://'].proxy_manager[self.proxies['https']]
            auth_map = {'Proxy-Authorization': self.proxy_auth}
            proxy_mgr.proxy_headers = auth_map
            proxy_mgr.connection_pool_kw['_proxy_headers'] = auth_map
            conns = proxy_mgr.pools._container
            for conn in conns:
                connection = conns[conn]
                connection.proxy_headers = auth_map
        return session
def _init_session ( self ) : session = requests . Session ( ) session . headers = { 'User-Agent' : self . user_agent , 'Accept' : 'application/json' } if self . systemid is not None : session . headers . update ( { 'systemid' : self . systemid } ) if self . authmethod == "BASIC" : session . auth = ( self . username , self . password ) elif self . authmethod == "CERT" : cert = rhsmCertificate . certpath ( ) key = rhsmCertificate . keypath ( ) if rhsmCertificate . exists ( ) : session . cert = ( cert , key ) else : logger . error ( 'ERROR: Certificates not found.' ) session . verify = self . cert_verify session . proxies = self . proxies session . trust_env = False if self . proxy_auth : try : net_logger . info ( "GET %s" , self . base_url ) session . request ( "GET" , self . base_url , timeout = self . config . http_timeout ) except requests . ConnectionError : pass proxy_mgr = session . adapters [ 'https://' ] . proxy_manager [ self . proxies [ 'https' ] ] auth_map = { 'Proxy-Authorization' : self . proxy_auth } proxy_mgr . proxy_headers = auth_map proxy_mgr . connection_pool_kw [ '_proxy_headers' ] = auth_map conns = proxy_mgr . pools . _container for conn in conns : connection = conns [ conn ] connection . proxy_headers = auth_map return session
Set up the session, auth is handled here
Set up the session auth is handled here
"""
        Set up the session, auth is handled here
        """ # HACKY # Need to make a request that will fail to get proxies set up # Major hack, requests/urllib3 does not make access to # proxy_headers easy
self