dbot-server/microraiden/client/atn.py
def _request_resource(
            self,
            method: str,
            url: str,
            **kwargs
    ) -> Tuple[Union[None, Response], bool]:
        """
        Performs a simple GET request to the HTTP server with headers representing the given
        channel state.
        """
        headers = Munch()
        headers.contract_address = self.client.context.channel_manager.address
        if self.channel is not None:
            headers.balance = str(self.channel.balance)
            headers.balance_signature = encode_hex(self.channel.balance_sig)
            headers.sender_address = self.channel.sender
            headers.receiver_address = self.channel.receiver
            headers.open_block = str(self.channel.block)

        headers = HTTPHeaders.serialize(headers)
        if 'headers' in kwargs:
            headers.update(kwargs['headers'])
            kwargs['headers'] = headers
        else:
            kwargs['headers'] = headers
        response = requests.request(method, url, **kwargs)

        if self.on_http_response(method, url, response, **kwargs) is False:
            return response, False  # user requested abort

        if response.status_code == requests.codes.OK:
            return response, self.on_success(method, url, response, **kwargs)

        elif response.status_code == requests.codes.PAYMENT_REQUIRED:
            if HTTPHeaders.NONEXISTING_CHANNEL in response.headers:
                return response, self.on_nonexisting_channel(method, url, response, **kwargs)

            elif HTTPHeaders.INSUF_CONFS in response.headers:
                return response, self.on_insufficient_confirmations(
                    method,
                    url,
                    response,
                    **kwargs
                )

            elif HTTPHeaders.INVALID_PROOF in response.headers:
                return response, self.on_invalid_balance_proof(method, url, response, **kwargs)

            elif HTTPHeaders.CONTRACT_ADDRESS not in response.headers or not is_same_address(
                response.headers.get(HTTPHeaders.CONTRACT_ADDRESS),
                self.client.context.channel_manager.address
            ):
                return response, self.on_invalid_contract_address(method, url, response, **kwargs)

            elif HTTPHeaders.INVALID_AMOUNT in response.headers:
                return response, self.on_invalid_amount(method, url, response, **kwargs)

            else:
                return response, self.on_payment_requested(method, url, response, **kwargs)
        else:
            return response, self.on_http_error(method, url, response, **kwargs)

        Performs a simple GET request to the HTTP server with headers representing the given
        channel state.
        
Performs a simple GET request to the HTTP server with headers representing the given
channel state.
Performs a simple GET request to the HTTP server with headers representing the given channel state .
def _request_resource(
            self,
            method: str,
            url: str,
            **kwargs
    ) -> Tuple[Union[None, Response], bool]:
        headers = Munch()
        headers.contract_address = self.client.context.channel_manager.address
        if self.channel is not None:
            headers.balance = str(self.channel.balance)
            headers.balance_signature = encode_hex(self.channel.balance_sig)
            headers.sender_address = self.channel.sender
            headers.receiver_address = self.channel.receiver
            headers.open_block = str(self.channel.block)
        headers = HTTPHeaders.serialize(headers)
        if 'headers' in kwargs:
            headers.update(kwargs['headers'])
            kwargs['headers'] = headers
        else:
            kwargs['headers'] = headers
        response = requests.request(method, url, **kwargs)
        if self.on_http_response(method, url, response, **kwargs) is False:
            return response, False  
        if response.status_code == requests.codes.OK:
            return response, self.on_success(method, url, response, **kwargs)
        elif response.status_code == requests.codes.PAYMENT_REQUIRED:
            if HTTPHeaders.NONEXISTING_CHANNEL in response.headers:
                return response, self.on_nonexisting_channel(method, url, response, **kwargs)
            elif HTTPHeaders.INSUF_CONFS in response.headers:
                return response, self.on_insufficient_confirmations(
                    method,
                    url,
                    response,
                    **kwargs
                )
            elif HTTPHeaders.INVALID_PROOF in response.headers:
                return response, self.on_invalid_balance_proof(method, url, response, **kwargs)
            elif HTTPHeaders.CONTRACT_ADDRESS not in response.headers or not is_same_address(
                response.headers.get(HTTPHeaders.CONTRACT_ADDRESS),
                self.client.context.channel_manager.address
            ):
                return response, self.on_invalid_contract_address(method, url, response, **kwargs)
            elif HTTPHeaders.INVALID_AMOUNT in response.headers:
                return response, self.on_invalid_amount(method, url, response, **kwargs)
            else:
                return response, self.on_payment_requested(method, url, response, **kwargs)
        else:
            return response, self.on_http_error(method, url, response, **kwargs)
def _request_resource ( self , method : str , url : str , ** kwargs ) -> Tuple [ Union [ None , Response ] , bool ] : headers = Munch ( ) headers . contract_address = self . client . context . channel_manager . address if self . channel is not None : headers . balance = str ( self . channel . balance ) headers . balance_signature = encode_hex ( self . channel . balance_sig ) headers . sender_address = self . channel . sender headers . receiver_address = self . channel . receiver headers . open_block = str ( self . channel . block ) headers = HTTPHeaders . serialize ( headers ) if 'headers' in kwargs : headers . update ( kwargs [ 'headers' ] ) kwargs [ 'headers' ] = headers else : kwargs [ 'headers' ] = headers response = requests . request ( method , url , ** kwargs ) if self . on_http_response ( method , url , response , ** kwargs ) is False : return response , False if response . status_code == requests . codes . OK : return response , self . on_success ( method , url , response , ** kwargs ) elif response . status_code == requests . codes . PAYMENT_REQUIRED : if HTTPHeaders . NONEXISTING_CHANNEL in response . headers : return response , self . on_nonexisting_channel ( method , url , response , ** kwargs ) elif HTTPHeaders . INSUF_CONFS in response . headers : return response , self . on_insufficient_confirmations ( method , url , response , ** kwargs ) elif HTTPHeaders . INVALID_PROOF in response . headers : return response , self . on_invalid_balance_proof ( method , url , response , ** kwargs ) elif HTTPHeaders . CONTRACT_ADDRESS not in response . headers or not is_same_address ( response . headers . get ( HTTPHeaders . CONTRACT_ADDRESS ) , self . client . context . channel_manager . address ) : return response , self . on_invalid_contract_address ( method , url , response , ** kwargs ) elif HTTPHeaders . INVALID_AMOUNT in response . headers : return response , self . on_invalid_amount ( method , url , response , ** kwargs ) else : return response , self . on_payment_requested ( method , url , response , ** kwargs ) else : return response , self . on_http_error ( method , url , response , ** kwargs )
Performs a simple GET request to the HTTP server with headers representing the given
channel state.
Performs a simple GET request to the HTTP server with headers representing the given channel state .
"""
        Performs a simple GET request to the HTTP server with headers representing the given
        channel state.
        """ # user requested abort
self
method
str
url
str