mokr.network.fetch ================== .. py:module:: mokr.network.fetch Classes ------- .. autoapisummary:: mokr.network.fetch.FetchDomain Module Contents --------------- .. py:class:: FetchDomain(page: mokr.browser.page.Page) Bases: :py:obj:`pyee.EventEmitter` Client to handle sending manual fetch requests. Note that sending fetch requests from this class will temporarily enable request interception globally. However, these fetch requests won't be caught by the request interception chain, however "response" and "requestfinished" events will still be caught. For Firefox this is not applicable. Fetch requests in Firefox are built manually from the response data. Unlike standard Firefox request responses, the response body is available for `FetchDomain` responses. Chrome requests take advantage of the existing fetch system in its `mokr.network.NetworkManager` while Firefox cannot; Chrome could do the same as Firefox does here and build the objects directly but some features would be lost like redirect chain. :param page: Parent `mokr.browser.Page` this was spawned from. :type page: Page .. py:method:: fetch(url: str | None = None, timeout: int = None, request: mokr.network.request.Request | None = None, body: str | None = None, browsing_topics: bool | None = None, cache: mokr.constants.HTTP_CACHE_TYPES | None = None, credentials: Literal['omit', 'same-origin', 'include'] | None = None, headers: dict | None = None, method: mokr.constants.HTTP_METHODS = 'GET', mode: Literal['cors', 'no-cors', 'same-origin'] = None, priority: Literal['high', 'low', 'auto'] | None = None, redirect: Literal['follow', 'error', 'manual'] | None = None, referrer: str | None = None, referrer_policy: mokr.constants.REFERRER_POLICIES | None = None) -> mokr.network.response.Response :async: Send a fetch request. Note that fetch is sensitive to the current site's CORS settings. Additionally, trying to send a fetch request before the DOM loads can hang forever. :param url: The url to request. Ignored if `request` is given. Defaults to None. :type url: str | None, optional :param timeout: Time in milliseconds to wait. Defaults to None. :type timeout: int, optional :param request: A request object to pull `url`, `method`, and `headers` from. Defaults to None. :type request: Request | None, optional :param body: Body to add to the request. Defaults to None. :type body: str | None, optional :param browsing_topics: If True, selected topics will be sent in a Sec-Browsing-Topics header with the associated request. Defaults to None. :type browsing_topics: bool | None, optional :param cache: How the request should interact with the HTTP cache. One of: "default", "no-store", "reload", "no-cache", "force-cache", or "only-if-cache". Defaults to None. :type cache: HTTP_CACHE_TYPES :param credentials: How to handle credentials. One of "omit", "same-origin", or "include". Defaults to None. :type credentials: Literal[str] | None, optional :param headers: Headers to pass with the request. Defaults to None. :type headers: dict | None, optional :param method: HTTP method. Defaults to "GET". :type method: HTTP_METHODS, optional :param mode: CORS mode to use. Defaults to None. :type mode: Literal["cors", "no-cors", "same-origin"], optional :param priority: Priority of request relative to others. Defaults to None. :type priority: Literal["high", "low", "auto"] | None, optional :param redirect: How to handle redirects. Defaults to None ("follow"). :type redirect: Literal["follow", "error", "manual"] | None, optional :param referrer: Request referrer. Defaults to None. :type referrer: str | None, optional :param referrer_policy: The referrer policy to use. One of "no-referrer", "no-referrer-when-downgrade", "same-origin", "origin", "strict-origin", "origin-when-cross-origin", "strict-origin-when-cross-origin", or "unsafe-url". Defaults to None ("strict-origin-when-cross-origin"). :type referrer_policy: REFERRER_POLICIES :raises ValueError: Raised if neither `url` nor `request` given. :raises NetworkError: Raised if no response found when request resolves. :returns: Last response recieved after all redirects, if any. :rtype: Response