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

Classes

class  HassHttpXAsyncClient
 

Functions

None _async_register_async_client_shutdown (HomeAssistant hass, httpx.AsyncClient client, Callable[[], Coroutine[Any, Any, None]] original_aclose)
 
httpx.AsyncClient create_async_httpx_client (HomeAssistant hass, bool verify_ssl=True, bool auto_cleanup=True, SSLCipherList ssl_cipher_list=SSLCipherList.PYTHON_DEFAULT, **Any kwargs)
 
httpx.AsyncClient get_async_client (HomeAssistant hass, bool verify_ssl=True)
 

Variables

 DEFAULT_LIMITS = httpx.Limits(keepalive_expiry=KEEP_ALIVE_TIMEOUT)
 
int KEEP_ALIVE_TIMEOUT = 15
 
tuple SERVER_SOFTWARE
 
string USER_AGENT = "User-Agent"
 

Detailed Description

Helper for httpx.

Function Documentation

◆ _async_register_async_client_shutdown()

None homeassistant.helpers.httpx_client._async_register_async_client_shutdown ( HomeAssistant  hass,
httpx.AsyncClient  client,
Callable[[], Coroutine[Any, Any, None]]  original_aclose 
)
private
Register httpx AsyncClient aclose on Home Assistant shutdown.

This method must be run in the event loop.

Definition at line 105 of file httpx_client.py.

◆ create_async_httpx_client()

httpx.AsyncClient homeassistant.helpers.httpx_client.create_async_httpx_client ( HomeAssistant  hass,
bool   verify_ssl = True,
bool   auto_cleanup = True,
SSLCipherList   ssl_cipher_list = SSLCipherList.PYTHON_DEFAULT,
**Any  kwargs 
)
Create a new httpx.AsyncClient with kwargs, i.e. for cookies.

If auto_cleanup is False, the client will be
automatically closed on homeassistant_stop.

This method must be run in the event loop.

Definition at line 66 of file httpx_client.py.

◆ get_async_client()

httpx.AsyncClient homeassistant.helpers.httpx_client.get_async_client ( HomeAssistant  hass,
bool   verify_ssl = True 
)
Return default httpx AsyncClient.

This method must be run in the event loop.

Definition at line 41 of file httpx_client.py.

Variable Documentation

◆ DEFAULT_LIMITS

homeassistant.helpers.httpx_client.DEFAULT_LIMITS = httpx.Limits(keepalive_expiry=KEEP_ALIVE_TIMEOUT)

Definition at line 31 of file httpx_client.py.

◆ KEEP_ALIVE_TIMEOUT

int homeassistant.helpers.httpx_client.KEEP_ALIVE_TIMEOUT = 15

Definition at line 26 of file httpx_client.py.

◆ SERVER_SOFTWARE

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

Definition at line 32 of file httpx_client.py.

◆ USER_AGENT

string homeassistant.helpers.httpx_client.USER_AGENT = "User-Agent"

Definition at line 36 of file httpx_client.py.