MCPcopy
hub / github.com/encode/httpx / handle_async_request

Method handle_async_request

httpx/_transports/default.py:374–403  ·  view source on GitHub ↗
(
        self,
        request: Request,
    )

Source from the content-addressed store, hash-verified

372 await self._pool.__aexit__(exc_type, exc_value, traceback)
373
374 async def handle_async_request(
375 self,
376 request: Request,
377 ) -> Response:
378 assert isinstance(request.stream, AsyncByteStream)
379 import httpcore
380
381 req = httpcore.Request(
382 method=request.method,
383 url=httpcore.URL(
384 scheme=request.url.raw_scheme,
385 host=request.url.raw_host,
386 port=request.url.port,
387 target=request.url.raw_path,
388 ),
389 headers=request.headers.raw,
390 content=request.stream,
391 extensions=request.extensions,
392 )
393 with map_httpcore_exceptions():
394 resp = await self._pool.handle_async_request(req)
395
396 assert isinstance(resp.stream, typing.AsyncIterable)
397
398 return Response(
399 status_code=resp.status,
400 headers=resp.headers,
401 stream=AsyncResponseStream(resp.stream),
402 extensions=resp.extensions,
403 )
404
405 async def aclose(self) -> None:
406 await self._pool.aclose()

Callers

nothing calls this directly

Calls 3

map_httpcore_exceptionsFunction · 0.85
ResponseClass · 0.85
AsyncResponseStreamClass · 0.85

Tested by

no test coverage detected