Exemplo n.º 1
0
 def send_request(self, request):
     resp = self.session.request(request.method,
                                 request.url,
                                 headers=request.headers,
                                 data=request.body,
                                 timeout=self.config.timeout,
                                 **self.options)
     return process_response(resp.status_code, resp.text)
Exemplo n.º 2
0
 def send_request(self, request):
     resp = urlfetch.fetch(url=request.url,
                           headers=request.headers,
                           method=request.method,
                           payload=request.body,
                           deadline=self.config.timeout,
                           **self.options)
     return process_response(resp.status_code, resp.content)
Exemplo n.º 3
0
        def process_response_future(response):
            if response.exception() is not None:
                future.set_exception(response.exception())

            else:
                result = response.result()
                code = result.code
                body = (result.body or b'').decode('utf8')
                future.set_result(process_response(code, body))
Exemplo n.º 4
0
        def process_response_future(response):
            if response.exception() is not None:
                future.set_exception(response.exception())

            else:
                result = response.result()
                code = result.code
                body = (result.body or b'').decode('utf8')
                future.set_result(process_response(code, body))
Exemplo n.º 5
0
    def send_request(self, request):
        resp = urlfetch.fetch(
            url=request.url,
            headers=request.headers,
            method=request.method,
            payload=request.body,
            deadline=self.client.timeout,
            **self.options)

        return process_response(resp.status_code, resp.content)
Exemplo n.º 6
0
    def send_request(self, request):
        resp = self.session.request(
            request.method,
            request.url,
            headers=request.headers,
            data=request.body,
            timeout=self.client.timeout,
            **self.options)

        return process_response(resp.status_code, resp.text)
Exemplo n.º 7
0
    def send_request(self, request):
        method = request.method
        url = "%s%s" % (request.base_url, request.path)
        params = request.query_params
        data = request.body
        headers = request.headers

        response = yield from asyncio.wait_for(
            aiohttp.request(method, url, params=params, data=data, headers=headers, connector=self.conn),
            timeout=self.config.timeout
        )
        body = yield from response.read_and_close()
        return process_response(response.status, body.decode('utf8'))
Exemplo n.º 8
0
    def send_request(self, request):
        method = request.method
        url = "%s%s" % (request.base_url, request.path)
        params = request.query_params
        data = request.body
        headers = request.headers

        response = yield from asyncio.wait_for(aiohttp.request(
            method,
            url,
            params=params,
            data=data,
            headers=headers,
            connector=self.conn),
                                               timeout=self.config.timeout)
        body = yield from response.read_and_close()
        return process_response(response.status, body.decode('utf8'))
Exemplo n.º 9
0
 def send_request(self, request):
     session = response = None
     try:
         session = aiohttp.ClientSession()
         response = yield from session.request(
             request.method,
             "%s%s" % (request.base_url, request.path),
             params=request.query_params,
             data=request.body,
             headers=request.headers,
             timeout=self.client.timeout)
         body = yield from response.text('utf-8')
         return process_response(response.status, body)
     finally:
         if response is not None:
             response.close()
         if session is not None:
             yield from session.close()
Exemplo n.º 10
0
 def send_request(self, request):
     session = response = None
     try:
         session = aiohttp.ClientSession()
         response = yield from session.request(
             request.method,
             "%s%s" % (request.base_url, request.path),
             params=request.query_params,
             data=request.body,
             headers=request.headers,
             timeout=self.client.timeout
         )
         body = yield from response.text('utf-8')
         return process_response(response.status, body)
     finally:
         if response is not None:
             response.close()
         if session is not None:
             yield from session.close()