corehttp.transport.aiohttp package

class corehttp.transport.aiohttp.AioHttpTransport(*, session: ClientSession | None = None, session_owner: bool = True, **kwargs)[source]

AioHttp HTTP sender implementation.

Fully asynchronous implementation using the aiohttp library.

Keyword Arguments:
  • session (ClientSession) – The client session.

  • session_owner (bool) – Session owner. Defaults True.

  • use_env_settings (bool) – Uses proxy settings from environment. Defaults to True.

async close()[source]

Closes the connection.

async open()[source]

Opens the connection.

async send(request: RestHttpRequest, *, stream: bool = False, proxies: MutableMapping[str, str] | None = None, **config) RestAsyncHttpResponse[source]

Send the request using this HTTP sender.

Will pre-load the body into memory to be available with a sync method. Pass stream=True to avoid this behavior.

Parameters:

request (HttpRequest) – The HttpRequest object

Keyword Arguments:
  • stream (bool) – Defaults to False.

  • proxies (MutableMapping) – dict of proxies to use based on protocol. Proxy is a dict (protocol, url).

Returns:

The AsyncHttpResponse

Return type:

AsyncHttpResponse

async sleep(duration: float) None

Sleep for the specified duration.

You should always ask the transport to sleep, and not call directly the stdlib. This is mostly important in async, as the transport may not use asyncio but other implementation like trio and they their own way to sleep, but to keep design consistent, it’s cleaner to always ask the transport to sleep and let the transport implementor decide how to do it. By default, this method will use “asyncio”, and don’t need to be overridden if your transport does too.

Parameters:

duration (float) – The number of seconds to sleep.