tdk.internal.http

This module provides helper functions for making HTTP requests.

Module Contents

Functions

session_maker

Create a aiohttp.ClientSession with some default headers.

make_http_session_optional

Make aiohttp.ClientSession optional for functions that require it.

Data

default_headers

Default headers for HTTP requests.

API

tdk.internal.http.default_headers: dict[str, str]

None

Default headers for HTTP requests.

tdk.internal.http.session_maker(**kwargs) aiohttp.ClientSession

Create a aiohttp.ClientSession with some default headers.

This is preferred over creating a base aiohttp.ClientSession because the TDK servers block requests that do not have headers.

Parameters:

kwargs

Additional arguments to be passed to aiohttp.ClientSession.

Important

If a headers argument is provided in kwargs, it will be modified to include the mandatory headers. Therefore it must be a collections.abc.MutableMapping.

Raises:

TypeError – if a headers argument is provided and it is not a collections.abc.MutableMapping.

tdk.internal.http.make_http_session_optional(func)

Make aiohttp.ClientSession optional for functions that require it.

Creates a decorator that provides a default aiohttp.ClientSession created by session_maker to the wrapped function.