iota/adapter/__init__.py
def _send_http_request(self, url, payload, method='post', **kwargs):
        # type: (Text, Optional[Text], Text, dict) -> Response
        """
        Sends the actual HTTP request.

        Split into its own method so that it can be mocked during unit
        tests.
        """
        kwargs.setdefault(
            'timeout',
            self.timeout if self.timeout else get_default_timeout(),
        )

        if self.authentication:
            kwargs.setdefault('auth', auth.HTTPBasicAuth(*self.authentication))

        self._log(
            level=DEBUG,

            message='Sending {method} to {url}: {payload!r}'.format(
                method=method,
                payload=payload,
                url=url,
            ),

            context={
                'request_method': method,
                'request_kwargs': kwargs,
                'request_payload': payload,
                'request_url': url,
            },
        )

        response = request(method=method, url=url, data=payload, **kwargs)

        self._log(
            level=DEBUG,

            message='Receiving {method} from {url}: {response!r}'.format(
                method=method,
                response=response.content,
                url=url,
            ),

            context={
                'request_method': method,
                'request_kwargs': kwargs,
                'request_payload': payload,
                'request_url': url,

                'response_headers': response.headers,
                'response_content': response.content,
            },
        )

        return response
def _send_http_request(self, url, payload, method='post', **kwargs):
        # type: (Text, Optional[Text], Text, dict) -> Response
        """
        Sends the actual HTTP request.

        Split into its own method so that it can be mocked during unit
        tests.
        """
        kwargs.setdefault(
            'timeout',
            self.timeout if self.timeout else get_default_timeout(),
        )

        if self.authentication:
            kwargs.setdefault('auth', auth.HTTPBasicAuth(*self.authentication))

        self._log(
            level=DEBUG,

            message='Sending {method} to {url}: {payload!r}'.format(
                method=method,
                payload=payload,
                url=url,
            ),

            context={
                'request_method': method,
                'request_kwargs': kwargs,
                'request_payload': payload,
                'request_url': url,
            },
        )

        response = request(method=method, url=url, data=payload, **kwargs)

        self._log(
            level=DEBUG,

            message='Receiving {method} from {url}: {response!r}'.format(
                method=method,
                response=response.content,
                url=url,
            ),

            context={
                'request_method': method,
                'request_kwargs': kwargs,
                'request_payload': payload,
                'request_url': url,

                'response_headers': response.headers,
                'response_content': response.content,
            },
        )

        return response
def _send_http_request ( self , url , payload , method = 'post' , * * kwargs ) : # type: (Text, Optional[Text], Text, dict) -> Response kwargs . setdefault ( 'timeout' , self . timeout if self . timeout else get_default_timeout ( ) , ) if self . authentication : kwargs . setdefault ( 'auth' , auth . HTTPBasicAuth ( * self . authentication ) ) self . _log ( level = DEBUG , message = 'Sending {method} to {url}: {payload!r}' . format ( method = method , payload = payload , url = url , ) , context = { 'request_method' : method , 'request_kwargs' : kwargs , 'request_payload' : payload , 'request_url' : url , } , ) response = request ( method = method , url = url , data = payload , * * kwargs ) self . _log ( level = DEBUG , message = 'Receiving {method} from {url}: {response!r}' . format ( method = method , response = response . content , url = url , ) , context = { 'request_method' : method , 'request_kwargs' : kwargs , 'request_payload' : payload , 'request_url' : url , 'response_headers' : response . headers , 'response_content' : response . content , } , ) return response
Sends the actual HTTP request.

        Split into its own method so that it can be mocked during unit
        tests.
Sends the actual HTTP request .