From: Florimond Manca Date: Sun, 1 Dec 2019 10:16:28 +0000 (+0100) Subject: Don't use background task in HTTP/1.1 dispatcher (#569) X-Git-Tag: 0.9.0~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f686012222ea34597c53d41d6b7e84d7b782038;p=thirdparty%2Fhttpx.git Don't use background task in HTTP/1.1 dispatcher (#569) --- diff --git a/httpx/dispatch/http11.py b/httpx/dispatch/http11.py index 058691a3..8202781b 100644 --- a/httpx/dispatch/http11.py +++ b/httpx/dispatch/http11.py @@ -46,10 +46,8 @@ class HTTP11Connection: timeout = None if timeout is None else TimeoutConfig(timeout) await self._send_request(request, timeout) - - task, args = self._send_request_data, [request.stream(), timeout] - async with self.backend.background_manager(task, *args): - http_version, status_code, headers = await self._receive_response(timeout) + await self._send_request_body(request, timeout) + http_version, status_code, headers = await self._receive_response(timeout) content = self._receive_response_data(timeout) return Response( @@ -89,15 +87,15 @@ class HTTP11Connection: event = h11.Request(method=method, target=target, headers=headers) await self._send_event(event, timeout) - async def _send_request_data( - self, data: typing.AsyncIterator[bytes], timeout: TimeoutConfig = None + async def _send_request_body( + self, request: Request, timeout: TimeoutConfig = None ) -> None: """ Send the request body to the network. """ try: # Send the request body. - async for chunk in data: + async for chunk in request.stream(): logger.trace(f"send_data data=Data(<{len(chunk)} bytes>)") event = h11.Data(data=chunk) await self._send_event(event, timeout)