src/domains/network

Search:
Group by:

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

Network domain allows tracking network activities of the page. It exposes information about http, file, data and other requests and responses, their headers, bodies, timing, etc.

Types

Network {.pure.} = enum
  dataReceived = "Network.dataReceived",
  eventSourceMessageReceived = "Network.eventSourceMessageReceived",
  loadingFailed = "Network.loadingFailed",
  loadingFinished = "Network.loadingFinished",
  requestServedFromCache = "Network.requestServedFromCache",
  requestWillBeSent = "Network.requestWillBeSent",
  responseReceived = "Network.responseReceived",
  webSocketClosed = "Network.webSocketClosed",
  webSocketCreated = "Network.webSocketCreated",
  webSocketFrameError = "Network.webSocketFrameError",
  webSocketFrameReceived = "Network.webSocketFrameReceived",
  webSocketFrameSent = "Network.webSocketFrameSent", webSocketHandshakeResponseReceived = "Network.webSocketHandshakeResponseReceived", webSocketWillSendHandshakeRequest = "Network.webSocketWillSendHandshakeRequest",
  webTransportClosed = "Network.webTransportClosed", webTransportConnectionEstablished = "Network.webTransportConnectionEstablished",
  webTransportCreated = "Network.webTransportCreated"
Network Domain events

Procs

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

Network.clearBrowserCache

Clears browser cache.

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

Network.clearBrowserCookies

Clears browser cookies.

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

Network.deleteCookies

Deletes browser cookies with matching name and url or domain/path/partitionKey pair.

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

Network.disable

Disables network tracking, prevents network events from being sent to the client.

proc emulateNetworkConditions(tab: Tab; offline: bool; latency: float | int;
                              downloadThroughput: float | int;
                              uploadThroughput: float | int): owned(
    Future[void]) {....stackTrace: false.}
proc emulateNetworkConditions(tab: Tab; offline: bool; latency: float | int;
                              downloadThroughput: float | int;
                              uploadThroughput: float | int; params: JsonNode): owned(
    Future[void]) {....stackTrace: false.}

Network.emulateNetworkConditions

Activates emulation of network conditions.

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

Network.enable

Enables network tracking, network events will now be delivered to the client.

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

Network.getCookies

Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the cookies field.

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

Network.getRequestPostData

Returns post data sent with the request. Returns an error when no data was sent with the request.

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

Network.getReponseBody

Returns content served for the given request.

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

Network.setBypassServiceWorker

Toggles ignoring cache for each request.

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

Network.setCacheDisabled

Toggles ignoring cache for each request.

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

Network.setCookie

Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.

Note: return object is deprecated, so we are not returning it.

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

Network.setCookies

Sets given cookies.

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

Network.setExtraHTTPHeaders

Specifies whether to always send extra HTTP headers with the requests from this page.

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

Network.setUserAgentOverride

Allows overriding user agent with the given string.