mokr.network.http
Classes
Client to handle sending requests outside of the browser, while syncing |
Module Contents
- class mokr.network.http.HttpDomain(page: mokr.browser.page.Page, sync_cookies: Literal['both', 'http', 'page', 'none'] = 'both', **httpx_client_kwargs)
Client to handle sending requests outside of the browser, while syncing state between itself and the parent
mokr.browser.Page.This client uses
httpxso requests can be made with HTTP2.- Parameters:
page (Page) – Parent
mokr.browser.Pagethat this will sync with.sync_cookies (Literal["both", "http", "page", "none"], optional) – Whether to sync cookies between this client and the parent
mokr.browser.Pagebefore/after each request and response. Defaults to “both”.
- async send(url: str, method: mokr.constants.HTTP_METHODS = 'GET', params: dict | None = None, headers: dict | None = None, data: dict | None = None, json: dict | None = None, **httpx_request_kwargs) mokr.network.response.Response
Send an HTTP request.
- Parameters:
url (str) – The url to request.
method (Literal[str], optional) – HTTP method. Defaults to “GET”.
params (dict | None, optional) – Parameters to encode in the URL before sending. Defaults to None (omitted).
headers (dict | None, optional) – Additional headers to send with this request beyond what was set when the client was created. Defaults to None (omitted).
data (dict | None, optional) – Data payload to deliver with request (form-encoded data). Only for “PUT”, “POST”, and “PATCH”. Defaults to None (omitted).
json (dict | None, optional) – Data payload to deliver with request (JSON-encoded data). Only for “PUT”, “POST”, and “PATCH”. Defaults to None (omitted).
- Raises:
ValueError – Raised if invalid HTTP method given or
dataorjsonarguments given with incompatible methods.- Returns:
- A
mokr.network.Responsecreated from the httpx.Response. All redirects will also be created, and original requests and responses will be accessible from themokr.networkobjects.
- A
- Return type: