NetworkApi class

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.

Constructors

NetworkApi(Client _client)

Properties

hashCode int
The hash code for this object.
no setterinherited
onDataReceived Stream<DataReceivedEvent>
Fired when data chunk was received over the network.
no setter
onEventSourceMessageReceived Stream<EventSourceMessageReceivedEvent>
Fired when EventSource message is received.
no setter
onLoadingFailed Stream<LoadingFailedEvent>
Fired when HTTP request has failed to load.
no setter
onLoadingFinished Stream<LoadingFinishedEvent>
Fired when HTTP request has finished loading.
no setter
onReportingApiEndpointsChangedForOrigin Stream<ReportingApiEndpointsChangedForOriginEvent>
no setter
onReportingApiReportAdded Stream<ReportingApiReport>
Is sent whenever a new report is added. And after 'enableReportingApi' for all existing reports.
no setter
onReportingApiReportUpdated Stream<ReportingApiReport>
no setter
onRequestIntercepted Stream<RequestInterceptedEvent>
Details of an intercepted HTTP request, which must be either allowed, blocked, modified or mocked. Deprecated, use Fetch.requestPaused instead.
no setter
onRequestServedFromCache Stream<RequestId>
Fired if request ended up loading from cache.
no setter
onRequestWillBeSent Stream<RequestWillBeSentEvent>
Fired when page is about to send HTTP request.
no setter
onRequestWillBeSentExtraInfo Stream<RequestWillBeSentExtraInfoEvent>
Fired when additional information about a requestWillBeSent event is available from the network stack. Not every requestWillBeSent event will have an additional requestWillBeSentExtraInfo fired for it, and there is no guarantee whether requestWillBeSent or requestWillBeSentExtraInfo will be fired first for the same request.
no setter
onResourceChangedPriority Stream<ResourceChangedPriorityEvent>
Fired when resource loading priority is changed
no setter
onResponseReceived Stream<ResponseReceivedEvent>
Fired when HTTP response is available.
no setter
onResponseReceivedExtraInfo Stream<ResponseReceivedExtraInfoEvent>
Fired when additional information about a responseReceived event is available from the network stack. Not every responseReceived event will have an additional responseReceivedExtraInfo for it, and responseReceivedExtraInfo may be fired before or after responseReceived.
no setter
onSignedExchangeReceived Stream<SignedExchangeReceivedEvent>
Fired when a signed exchange was received over the network
no setter
onSubresourceWebBundleInnerResponseError Stream<SubresourceWebBundleInnerResponseErrorEvent>
Fired when request for resources within a .wbn file failed.
no setter
onSubresourceWebBundleInnerResponseParsed Stream<SubresourceWebBundleInnerResponseParsedEvent>
Fired when handling requests for resources within a .wbn file. Note: this will only be fired for resources that are requested by the webpage.
no setter
onSubresourceWebBundleMetadataError Stream<SubresourceWebBundleMetadataErrorEvent>
Fired once when parsing the .wbn file has failed.
no setter
onSubresourceWebBundleMetadataReceived Stream<SubresourceWebBundleMetadataReceivedEvent>
Fired once when parsing the .wbn file has succeeded. The event contains the information about the web bundle contents.
no setter
onTrustTokenOperationDone Stream<TrustTokenOperationDoneEvent>
Fired exactly once for each Trust Token operation. Depending on the type of the operation and whether the operation succeeded or failed, the event is fired before the corresponding request was sent or after the response was received.
no setter
onWebSocketClosed Stream<WebSocketClosedEvent>
Fired when WebSocket is closed.
no setter
onWebSocketCreated Stream<WebSocketCreatedEvent>
Fired upon WebSocket creation.
no setter
onWebSocketFrameError Stream<WebSocketFrameErrorEvent>
Fired when WebSocket message error occurs.
no setter
onWebSocketFrameReceived Stream<WebSocketFrameReceivedEvent>
Fired when WebSocket message is received.
no setter
onWebSocketFrameSent Stream<WebSocketFrameSentEvent>
Fired when WebSocket message is sent.
no setter
onWebSocketHandshakeResponseReceived Stream<WebSocketHandshakeResponseReceivedEvent>
Fired when WebSocket handshake response becomes available.
no setter
onWebSocketWillSendHandshakeRequest Stream<WebSocketWillSendHandshakeRequestEvent>
Fired when WebSocket is about to initiate handshake.
no setter
onWebTransportClosed Stream<WebTransportClosedEvent>
Fired when WebTransport is disposed.
no setter
onWebTransportConnectionEstablished Stream<WebTransportConnectionEstablishedEvent>
Fired when WebTransport handshake is finished.
no setter
onWebTransportCreated Stream<WebTransportCreatedEvent>
Fired upon WebTransport creation.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

canClearBrowserCache() Future<bool>
Tells whether clearing browser cache is supported. Returns: True if browser cache can be cleared.
canClearBrowserCookies() Future<bool>
Tells whether clearing browser cookies is supported. Returns: True if browser cookies can be cleared.
canEmulateNetworkConditions() Future<bool>
Tells whether emulation of network conditions is supported. Returns: True if emulation of network conditions is supported.
clearAcceptedEncodingsOverride() Future<void>
Clears accepted encodings set by setAcceptedEncodings
clearBrowserCache() Future<void>
Clears browser cache.
clearBrowserCookies() Future<void>
Clears browser cookies.
continueInterceptedRequest(InterceptionId interceptionId, {ErrorReason? errorReason, String? rawResponse, String? url, String? method, String? postData, Headers? headers, AuthChallengeResponse? authChallengeResponse}) Future<void>
Response to Network.requestIntercepted which either modifies the request to continue with any modifications, or blocks it, or completes it with the provided response bytes. If a network fetch occurs as a result which encounters a redirect an additional Network.requestIntercepted event will be sent with the same InterceptionId. Deprecated, use Fetch.continueRequest, Fetch.fulfillRequest and Fetch.failRequest instead. errorReason If set this causes the request to fail with the given reason. Passing Aborted for requests marked with isNavigationRequest also cancels the navigation. Must not be set in response to an authChallenge. rawResponse If set the requests completes using with the provided base64 encoded raw response, including HTTP status line and headers etc... Must not be set in response to an authChallenge. url If set the request url will be modified in a way that's not observable by page. Must not be set in response to an authChallenge. method If set this allows the request method to be overridden. Must not be set in response to an authChallenge. postData If set this allows postData to be set. Must not be set in response to an authChallenge. headers If set this allows the request headers to be changed. Must not be set in response to an authChallenge. authChallengeResponse Response to a requestIntercepted with an authChallenge. Must not be set otherwise.
deleteCookies(String name, {String? url, String? domain, String? path}) Future<void>
Deletes browser cookies with matching name and url or domain/path pair. name Name of the cookies to remove. url If specified, deletes all the cookies with the given name where domain and path match provided URL. domain If specified, deletes only cookies with the exact domain. path If specified, deletes only cookies with the exact path.
disable() Future<void>
Disables network tracking, prevents network events from being sent to the client.
emulateNetworkConditions(bool offline, num latency, num downloadThroughput, num uploadThroughput, {ConnectionType? connectionType}) Future<void>
Activates emulation of network conditions. offline True to emulate internet disconnection. latency Minimum latency from request sent to response headers received (ms). downloadThroughput Maximal aggregated download throughput (bytes/sec). -1 disables download throttling. uploadThroughput Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. connectionType Connection type if known.
enable({int? maxTotalBufferSize, int? maxResourceBufferSize, int? maxPostDataSize}) Future<void>
Enables network tracking, network events will now be delivered to the client. maxTotalBufferSize Buffer size in bytes to use when preserving network payloads (XHRs, etc). maxResourceBufferSize Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc). maxPostDataSize Longest post body size (in bytes) that would be included in requestWillBeSent notification
enableReportingApi(bool enable) Future<void>
Enables tracking for the Reporting API, events generated by the Reporting API will now be delivered to the client. Enabling triggers 'reportingApiReportAdded' for all existing reports. enable Whether to enable or disable events for the Reporting API
getAllCookies() Future<List<Cookie>>
Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the cookies field. Deprecated. Use Storage.getCookies instead. Returns: Array of cookie objects.
getCertificate(String origin) Future<List<String>>
Returns the DER-encoded certificate. origin Origin to get certificate for.
getCookies({List<String>? urls}) Future<List<Cookie>>
Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the cookies field. urls The list of URLs for which applicable cookies will be fetched. If not specified, it's assumed to be set to the list containing the URLs of the page and all of its subframes. Returns: Array of cookie objects.
getRequestPostData(RequestId requestId) Future<String>
Returns post data sent with the request. Returns an error when no data was sent with the request. requestId Identifier of the network request to get content for. Returns: Request body string, omitting files from multipart requests
getResponseBody(RequestId requestId) Future<GetResponseBodyResult>
Returns content served for the given request. requestId Identifier of the network request to get content for.
getResponseBodyForInterception(InterceptionId interceptionId) Future<GetResponseBodyForInterceptionResult>
Returns content served for the given currently intercepted request. interceptionId Identifier for the intercepted request to get body for.
getSecurityIsolationStatus({FrameId? frameId}) Future<SecurityIsolationStatus>
Returns information about the COEP/COOP isolation status. frameId If no frameId is provided, the status of the target is provided.
loadNetworkResource(String url, LoadNetworkResourceOptions options, {FrameId? frameId}) Future<LoadNetworkResourcePageResult>
Fetches the resource and returns the content. frameId Frame id to get the resource for. Mandatory for frame targets, and should be omitted for worker targets. url URL of the resource to get content for. options Options for the request.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
replayXHR(RequestId requestId) Future<void>
This method sends a new XMLHttpRequest which is identical to the original one. The following parameters should be identical: method, url, async, request body, extra headers, withCredentials attribute, user, password. requestId Identifier of XHR to replay.
searchInResponseBody(RequestId requestId, String query, {bool? caseSensitive, bool? isRegex}) Future<List<SearchMatch>>
Searches for given string in response content. requestId Identifier of the network response to search. query String to search for. caseSensitive If true, search is case sensitive. isRegex If true, treats string parameter as regex. Returns: List of search matches.
setAcceptedEncodings(List<ContentEncoding> encodings) Future<void>
Sets a list of content encodings that will be accepted. Empty list means no encoding is accepted. encodings List of accepted content encodings.
setAttachDebugStack(bool enabled) Future<void>
Specifies whether to attach a page script stack id in requests enabled Whether to attach a page script stack for debugging purpose.
setBlockedURLs(List<String> urls) Future<void>
Blocks URLs from loading. urls URL patterns to block. Wildcards ('*') are allowed.
setBypassServiceWorker(bool bypass) Future<void>
Toggles ignoring of service worker for each request. bypass Bypass service worker and load from network.
setCacheDisabled(bool cacheDisabled) Future<void>
Toggles ignoring cache for each request. If true, cache will not be used. cacheDisabled Cache disabled state.
setCookie(String name, String value, {String? url, String? domain, String? path, bool? secure, bool? httpOnly, CookieSameSite? sameSite, TimeSinceEpoch? expires, CookiePriority? priority, bool? sameParty, CookieSourceScheme? sourceScheme, int? sourcePort, String? partitionKey}) Future<bool>
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist. name Cookie name. value Cookie value. url The request-URI to associate with the setting of the cookie. This value can affect the default domain, path, source port, and source scheme values of the created cookie. domain Cookie domain. path Cookie path. secure True if cookie is secure. httpOnly True if cookie is http-only. sameSite Cookie SameSite type. expires Cookie expiration date, session cookie if not set priority Cookie Priority type. sameParty True if cookie is SameParty. sourceScheme Cookie source scheme type. sourcePort Cookie source port. Valid values are {-1, 1, 65535}, -1 indicates an unspecified port. An unspecified port value allows protocol clients to emulate legacy cookie scope for the port. This is a temporary ability and it will be removed in the future. partitionKey Cookie partition key. The site of the top-level URL the browser was visiting at the start of the request to the endpoint that set the cookie. If not set, the cookie will be set as not partitioned. Returns: Always set to true. If an error occurs, the response indicates protocol error.
setCookies(List<CookieParam> cookies) Future<void>
Sets given cookies. cookies Cookies to be set.
setExtraHTTPHeaders(Headers headers) Future<void>
Specifies whether to always send extra HTTP headers with the requests from this page. headers Map with extra HTTP headers.
setRequestInterception(List<RequestPattern> patterns) Future<void>
Sets the requests to intercept that match the provided patterns and optionally resource types. Deprecated, please use Fetch.enable instead. patterns Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.
setUserAgentOverride(String userAgent, {String? acceptLanguage, String? platform, UserAgentMetadata? userAgentMetadata}) Future<void>
Allows overriding user agent with the given string. userAgent User agent to use. acceptLanguage Browser language to emulate. platform The platform navigator.platform should return. userAgentMetadata To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
streamResourceContent(RequestId requestId) Future<String>
Enables streaming of the response for the given requestId. If enabled, the dataReceived event contains the data that was received during streaming. requestId Identifier of the request to stream. Returns: Data that has been buffered until streaming is enabled.
takeResponseBodyForInterceptionAsStream(InterceptionId interceptionId) Future<StreamHandle>
Returns a handle to the stream representing the response body. Note that after this command, the intercepted request can't be continued as is -- you either need to cancel it or to provide the response body. The stream only supports sequential read, IO.read will fail if the position is specified.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited