Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.aiohttp_client Namespace Reference

Classes

class  HassClientResponse
 
class  HomeAssistantTCPConnector
 

Functions

aiohttp.ClientSession _async_create_clientsession (HomeAssistant hass, bool verify_ssl=True, Callable[[HomeAssistant, aiohttp.ClientSession], None]|None auto_cleanup_method=None, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT, **Any kwargs)
 
aiohttp.BaseConnector _async_get_connector (HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)
 
None _async_register_clientsession_shutdown (HomeAssistant hass, aiohttp.ClientSession clientsession)
 
None _async_register_default_clientsession_shutdown (HomeAssistant hass, aiohttp.ClientSession clientsession)
 
tuple[bool, socket.AddressFamily, ssl_util.SSLCipherList] _make_key (bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)
 
web.StreamResponse async_aiohttp_proxy_stream (HomeAssistant hass, web.BaseRequest request, aiohttp.StreamReader stream, str|None content_type, int buffer_size=102400, int timeout=10)
 
web.StreamResponse|None async_aiohttp_proxy_web (HomeAssistant hass, web.BaseRequest request, Awaitable[aiohttp.ClientResponse] web_coro, int buffer_size=102400, int timeout=10)
 
aiohttp.ClientSession async_create_clientsession (HomeAssistant hass, bool verify_ssl=True, bool auto_cleanup=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT, **Any kwargs)
 
aiohttp.ClientSession async_get_clientsession (HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)
 

Variables

tuple ENABLE_CLEANUP_CLOSED
 
int MAXIMUM_CONNECTIONS = 4096
 
int MAXIMUM_CONNECTIONS_PER_HOST = 100
 
tuple SERVER_SOFTWARE
 
string WARN_CLOSE_MSG = "closes the Home Assistant aiohttp session"
 

Detailed Description

Helper for aiohttp webclient stuff.

Function Documentation

◆ _async_create_clientsession()

aiohttp.ClientSession homeassistant.helpers.aiohttp_client._async_create_clientsession ( HomeAssistant  hass,
bool   verify_ssl = True,
Callable[[HomeAssistant, aiohttp.ClientSession], None] | None   auto_cleanup_method = None,
socket.AddressFamily   family = socket.AF_UNSPEC,
ssl_util.SSLCipherList   ssl_cipher = ssl_util.SSLCipherList.PYTHON_DEFAULT,
**Any  kwargs 
)
private
Create a new ClientSession with kwargs, i.e. for cookies.

Definition at line 149 of file aiohttp_client.py.

◆ _async_get_connector()

aiohttp.BaseConnector homeassistant.helpers.aiohttp_client._async_get_connector ( HomeAssistant  hass,
bool   verify_ssl = True,
socket.AddressFamily   family = socket.AF_UNSPEC,
ssl_util.SSLCipherList   ssl_cipher = ssl_util.SSLCipherList.PYTHON_DEFAULT 
)
private
Return the connector pool for aiohttp.

This method must be run in the event loop.

Definition at line 313 of file aiohttp_client.py.

◆ _async_register_clientsession_shutdown()

None homeassistant.helpers.aiohttp_client._async_register_clientsession_shutdown ( HomeAssistant  hass,
aiohttp.ClientSession   clientsession 
)
private
Register ClientSession close on Home Assistant shutdown or config entry unload.

This method must be run in the event loop.

Definition at line 246 of file aiohttp_client.py.

◆ _async_register_default_clientsession_shutdown()

None homeassistant.helpers.aiohttp_client._async_register_default_clientsession_shutdown ( HomeAssistant  hass,
aiohttp.ClientSession   clientsession 
)
private
Register default ClientSession close on Home Assistant shutdown.

This method must be run in the event loop.

Definition at line 271 of file aiohttp_client.py.

◆ _make_key()

tuple[bool, socket.AddressFamily, ssl_util.SSLCipherList] homeassistant.helpers.aiohttp_client._make_key ( bool   verify_ssl = True,
socket.AddressFamily   family = socket.AF_UNSPEC,
ssl_util.SSLCipherList   ssl_cipher = ssl_util.SSLCipherList.PYTHON_DEFAULT 
)
private
Make a key for connector or session pool.

Definition at line 288 of file aiohttp_client.py.

◆ async_aiohttp_proxy_stream()

web.StreamResponse homeassistant.helpers.aiohttp_client.async_aiohttp_proxy_stream ( HomeAssistant  hass,
web.BaseRequest  request,
aiohttp.StreamReader  stream,
str | None  content_type,
int   buffer_size = 102400,
int   timeout = 10 
)
Stream a stream to aiohttp web response.

Definition at line 218 of file aiohttp_client.py.

◆ async_aiohttp_proxy_web()

web.StreamResponse | None homeassistant.helpers.aiohttp_client.async_aiohttp_proxy_web ( HomeAssistant  hass,
web.BaseRequest  request,
Awaitable[aiohttp.ClientResponse]  web_coro,
int   buffer_size = 102400,
int   timeout = 10 
)
Stream websession request to aiohttp web response.

Definition at line 185 of file aiohttp_client.py.

◆ async_create_clientsession()

aiohttp.ClientSession homeassistant.helpers.aiohttp_client.async_create_clientsession ( HomeAssistant  hass,
bool   verify_ssl = True,
bool   auto_cleanup = True,
socket.AddressFamily   family = socket.AF_UNSPEC,
ssl_util.SSLCipherList   ssl_cipher = ssl_util.SSLCipherList.PYTHON_DEFAULT,
**Any  kwargs 
)
Create a new ClientSession with kwargs, i.e. for cookies.

If auto_cleanup is False, you need to call detach() after the session
returned is no longer used. Default is True, the session will be
automatically detached on homeassistant_stop or when being created
in config entry setup, the config entry is unloaded.

This method must be run in the event loop.

Definition at line 117 of file aiohttp_client.py.

◆ async_get_clientsession()

aiohttp.ClientSession homeassistant.helpers.aiohttp_client.async_get_clientsession ( HomeAssistant  hass,
bool   verify_ssl = True,
socket.AddressFamily   family = socket.AF_UNSPEC,
ssl_util.SSLCipherList   ssl_cipher = ssl_util.SSLCipherList.PYTHON_DEFAULT 
)
Return default aiohttp ClientSession.

This method must be run in the event loop.

Definition at line 87 of file aiohttp_client.py.

Variable Documentation

◆ ENABLE_CLEANUP_CLOSED

tuple homeassistant.helpers.aiohttp_client.ENABLE_CLEANUP_CLOSED
Initial value:
1 = sys.version_info < (
2  3,
3  13,
4  1,
5 ) or sys.version_info < (3, 12, 7)

Definition at line 47 of file aiohttp_client.py.

◆ MAXIMUM_CONNECTIONS

int homeassistant.helpers.aiohttp_client.MAXIMUM_CONNECTIONS = 4096

Definition at line 68 of file aiohttp_client.py.

◆ MAXIMUM_CONNECTIONS_PER_HOST

int homeassistant.helpers.aiohttp_client.MAXIMUM_CONNECTIONS_PER_HOST = 100

Definition at line 69 of file aiohttp_client.py.

◆ SERVER_SOFTWARE

tuple homeassistant.helpers.aiohttp_client.SERVER_SOFTWARE
Initial value:
1 = (
2  f"{APPLICATION_NAME}/{__version__} "
3  f"aiohttp/{aiohttp.__version__} Python/{sys.version_info[0]}.{sys.version_info[1]}"
4 )

Definition at line 42 of file aiohttp_client.py.

◆ WARN_CLOSE_MSG

string homeassistant.helpers.aiohttp_client.WARN_CLOSE_MSG = "closes the Home Assistant aiohttp session"

Definition at line 55 of file aiohttp_client.py.