def request(self, url, params={}, headers={}):
        """
        Retrieve SDMX messages.
        If needed, override in subclasses to support other data providers.

        :param url: The URL of the message.
        :type url: str
        :return: the xml data as file-like object
        """
        # Generate current config. Merge in any given headers
        cur_config = self.config.copy()
        if 'headers' in cur_config:
            cur_config['headers'] = cur_config['headers'].copy()
            cur_config['headers'].update(headers)
        else:
            cur_config['headers'] = headers

        with closing(requests.get(url, params=params, **cur_config)) as response:
            if response.status_code == requests.codes.OK:
                # Prepare the temp file. xml content will be
                # stored in a binary file, json in a textfile.
                if (response.headers.get('Content-Type')
                        and ('json' in response.headers['Content-Type'])):
                    enc, fmode = response.encoding, 'w+t'
                else:
                    enc, fmode = None, 'w+b'
                # Create temp file ensuring 2to3 compatibility
                if str_type == str:  # we are on py3
                    source = STF(
                        max_size=self.max_size, mode=fmode, encoding=enc)
                else:
                    # On py27 we must omit the 'encoding' kwarg
                    source = STF(max_size=self.max_size, mode=fmode)
                for c in response.iter_content(chunk_size=1000000,
                                               decode_unicode=bool(enc)):
                    source.write(c)

            else:
                source = None
            code = int(response.status_code)
            if 400 <= code <= 499:
                raise response.raise_for_status()
            return source, response.url, response.headers, code
def request ( self , url , params = { } , headers = { } ) : cur_config = self . config . copy ( ) if 'headers' in cur_config : cur_config [ 'headers' ] = cur_config [ 'headers' ] . copy ( ) cur_config [ 'headers' ] . update ( headers ) else : cur_config [ 'headers' ] = headers with closing ( requests . get ( url , params = params , ** cur_config ) ) as response : if response . status_code == requests . codes . OK : if ( response . headers . get ( 'Content-Type' ) and ( 'json' in response . headers [ 'Content-Type' ] ) ) : enc , fmode = response . encoding , 'w+t' else : enc , fmode = None , 'w+b' if str_type == str : source = STF ( max_size = self . max_size , mode = fmode , encoding = enc ) else : source = STF ( max_size = self . max_size , mode = fmode ) for c in response . iter_content ( chunk_size = 1000000 , decode_unicode = bool ( enc ) ) : source . write ( c ) else : source = None code = int ( response . status_code ) if 400 <= code <= 499 : raise response . raise_for_status ( ) return source , response . url , response . headers , code
Retrieve SDMX messages.
        If needed, override in subclasses to support other data providers.

        :param url: The URL of the message.
        :type url: str
        :return: the xml data as file-like object