]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Don't use background task in HTTP/1.1 dispatcher (#569)
authorFlorimond Manca <florimond.manca@gmail.com>
Sun, 1 Dec 2019 10:16:28 +0000 (11:16 +0100)
committerTom Christie <tom@tomchristie.com>
Sun, 1 Dec 2019 10:16:28 +0000 (10:16 +0000)
httpx/dispatch/http11.py

index 058691a30e8674bc7f4295473ea0d417c447873f..8202781b6cffe699c2c5fef521d815f0d6eb0edf 100644 (file)
@@ -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)