def from_request(cls, http_method, http_url, headers=None, parameters=None,
            query_string=None):
        """Combines multiple parameter sources."""
        if parameters is None:
            parameters = {}
 
        # Headers
        if headers:
            auth_header = None
            for k, v in headers.items():
                if k.lower() == 'authorization' or \
                    k.upper() == 'HTTP_AUTHORIZATION':
                    auth_header = v

            # Check that the authorization header is OAuth.
            if auth_header and auth_header[:6] == 'OAuth ':
                auth_header = auth_header[6:]
                try:
                    # Get the parameters from the header.
                    header_params = cls._split_header(auth_header)
                    parameters.update(header_params)
                except:
                    raise Error('Unable to parse OAuth parameters from '
                        'Authorization header.')
 
        # GET or POST query string.
        if query_string:
            query_params = cls._split_url_string(query_string)

            parameters.update(query_params)
 
        # URL parameters.
        param_str = urlparse(http_url)[4] # query
        url_params = cls._split_url_string(param_str)
        parameters.update(url_params)
 
        if parameters:
            return cls(http_method, http_url, parameters)
 
        return None
def from_request ( cls , http_method , http_url , headers = None , parameters = None , query_string = None ) : if parameters is None : parameters = { } if headers : auth_header = None for k , v in headers . items ( ) : if k . lower ( ) == 'authorization' or k . upper ( ) == 'HTTP_AUTHORIZATION' : auth_header = v if auth_header and auth_header [ : 6 ] == 'OAuth ' : auth_header = auth_header [ 6 : ] try : header_params = cls . _split_header ( auth_header ) parameters . update ( header_params ) except : raise Error ( 'Unable to parse OAuth parameters from ' 'Authorization header.' ) if query_string : query_params = cls . _split_url_string ( query_string ) parameters . update ( query_params ) param_str = urlparse ( http_url ) [ 4 ] url_params = cls . _split_url_string ( param_str ) parameters . update ( url_params ) if parameters : return cls ( http_method , http_url , parameters ) return None
Combines multiple parameter sources.