src/domains/fetch

This module provides a direct mapping of CDP events and commands for v1.3 (stable) of the Fetch Domain.

Types

Fetch {.pure.} = enum
  authRequired = "Fetch.authRequired", requestPaused = "Fetch.requestPaused"
Fetch Domain events

Procs

proc continueRequest(tab: Tab; requestId: string): owned(Future[void]) {.
    ...stackTrace: false, raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc continueRequest(tab: Tab; requestId: string; params: JsonNode): owned(
    Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect,
    WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Fetch.continueRequest

Continues the request, optionally modifying some of its parameters.

proc continueWithAuth(tab: Tab; requestId: string;
                      authChallengeResponse: JsonNode): owned(Future[void]) {.
    ...stackTrace: false, raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Fetch.continueWithAuth

Continues a request supplying authChallengeResponse following authRequired event.

proc disableFetchDomain(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Fetch.disable

Disables the fetch domain.

proc enableFetchDomain(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc enableFetchDomain(tab: Tab; params: JsonNode): owned(Future[void]) {.
    ...stackTrace: false, raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Fetch.enable

Enables issuing of requestPaused events. A request will be paused until client calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.

proc failRequest(tab: Tab; requestId, errorReason: string): owned(
    Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect,
    WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Fetch.failRequest

Causes the request to fail with specified reason.

proc fulfillRequest(tab: Tab; requestId: string; responseCode: int): owned(
    Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect,
    WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc fulfillRequest(tab: Tab; requestId: string; responseCode: int;
                    params: JsonNode): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Fetch.fulfillRequest

Provides response to the request.

proc getResponseBodyFetchDomain(tab: Tab; requestId: string): Future[JsonNode] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Fetch.getResponseBody

Causes the body of the response to be received from the server and returned as a single string. May only be issued for a request that is paused in the Response stage and is mutually exclusive with takeResponseBodyForInterceptionAsStream. Calling other methods that affect the request or disabling fetch domain before body is received results in an undefined behavior.

Note that the response body is not available for redirects. Requests paused in the redirect received state may be differentiated by responseCode and presence of location response header, see comments to requestPaused for details.

proc takeResponseBodyAsStream(tab: Tab; requestId: string): Future[JsonNode] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

Fetch.takeResponseBodyAsStream

Returns a handle to the stream representing the response body. The request must be paused in the HeadersReceived stage.

Note that after this command the request can't be continued as is- client either needs to cancel it or to provide the response body. The stream only supports sequential read, IO.read will fail if the position is specified. This method is mutually exclusive with getResponseBody. Calling other methods that affect the request or disabling fetch domain before body is received results in an undefined behavior.