findmy.util.http ================ .. py:module:: findmy.util.http .. autoapi-nested-parse:: Module to simplify asynchronous HTTP calls. Classes ------- .. autoapisummary:: findmy.util.http.HttpResponse findmy.util.http.HttpSession Module Contents --------------- .. py:class:: HttpResponse(status_code: int, content: bytes) Response of a request made by `HttpSession`. .. py:property:: status_code :type: int HTTP status code of the response. .. py:property:: ok :type: bool Whether the status code is "OK" (2xx). .. py:method:: text() -> str Response content as a UTF-8 encoded string. .. py:method:: json() -> dict[Any, Any] Response content as a dict, obtained by JSON-decoding the response content. .. py:method:: plist() -> dict[Any, Any] Response content as a dict, obtained by Plist-decoding the response content. .. py:class:: HttpSession Bases: :py:obj:`findmy.util.closable.Closable` Asynchronous HTTP session manager. For internal use only. .. py:method:: close() -> None :async: Close the underlying session. Should be called when session will no longer be used. .. py:method:: request(method: str, url: str, **kwargs: typing_extensions.Unpack[_HttpRequestOptions]) -> HttpResponse :async: Make an HTTP request. Keyword arguments will directly be passed to `aiohttp.ClientSession.request`. .. py:method:: get(url: str, **kwargs: typing_extensions.Unpack[_HttpRequestOptions]) -> HttpResponse :async: Alias for `HttpSession.request("GET", ...)`. .. py:method:: post(url: str, **kwargs: typing_extensions.Unpack[_HttpRequestOptions]) -> HttpResponse :async: Alias for `HttpSession.request("POST", ...)`.