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.
errorReasonIf set this causes the request to fail with the given reason. PassingAbortedfor requests marked withisNavigationRequestalso cancels the navigation. Must not be set in response to an authChallenge.rawResponseIf 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.urlIf 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.methodIf set this allows the request method to be overridden. Must not be set in response to an authChallenge.postDataIf set this allows postData to be set. Must not be set in response to an authChallenge.headersIf set this allows the request headers to be changed. Must not be set in response to an authChallenge.authChallengeResponseResponse 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.
nameName of the cookies to remove.urlIf specified, deletes all the cookies with the given name where domain and path match provided URL.domainIf specified, deletes only cookies with the exact domain.pathIf 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.
offlineTrue to emulate internet disconnection.latencyMinimum latency from request sent to response headers received (ms).downloadThroughputMaximal aggregated download throughput (bytes/sec). -1 disables download throttling.uploadThroughputMaximal aggregated upload throughput (bytes/sec). -1 disables upload throttling.connectionTypeConnection type if known. -
enable(
{int? maxTotalBufferSize, int? maxResourceBufferSize, int? maxPostDataSize}) → Future< void> -
Enables network tracking, network events will now be delivered to the client.
maxTotalBufferSizeBuffer size in bytes to use when preserving network payloads (XHRs, etc).maxResourceBufferSizePer-resource buffer size in bytes to use when preserving network payloads (XHRs, etc).maxPostDataSizeLongest 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.
enableWhether 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
cookiesfield. Deprecated. Use Storage.getCookies instead. Returns: Array of cookie objects. -
getCertificate(
String origin) → Future< List< String> > -
Returns the DER-encoded certificate.
originOrigin 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
cookiesfield.urlsThe 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.
requestIdIdentifier 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.
requestIdIdentifier of the network request to get content for. -
getResponseBodyForInterception(
InterceptionId interceptionId) → Future< GetResponseBodyForInterceptionResult> -
Returns content served for the given currently intercepted request.
interceptionIdIdentifier for the intercepted request to get body for. -
getSecurityIsolationStatus(
{FrameId? frameId}) → Future< SecurityIsolationStatus> -
Returns information about the COEP/COOP isolation status.
frameIdIf 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.
frameIdFrame id to get the resource for. Mandatory for frame targets, and should be omitted for worker targets.urlURL of the resource to get content for.optionsOptions 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.
requestIdIdentifier of XHR to replay. -
searchInResponseBody(
RequestId requestId, String query, {bool? caseSensitive, bool? isRegex}) → Future< List< SearchMatch> > -
Searches for given string in response content.
requestIdIdentifier of the network response to search.queryString to search for.caseSensitiveIf true, search is case sensitive.isRegexIf 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.
encodingsList of accepted content encodings. -
setAttachDebugStack(
bool enabled) → Future< void> -
Specifies whether to attach a page script stack id in requests
enabledWhether to attach a page script stack for debugging purpose. -
setBlockedURLs(
List< String> urls) → Future<void> -
Blocks URLs from loading.
urlsURL patterns to block. Wildcards ('*') are allowed. -
setBypassServiceWorker(
bool bypass) → Future< void> -
Toggles ignoring of service worker for each request.
bypassBypass service worker and load from network. -
setCacheDisabled(
bool cacheDisabled) → Future< void> -
Toggles ignoring cache for each request. If
true, cache will not be used.cacheDisabledCache 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.
nameCookie name.valueCookie value.urlThe 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.domainCookie domain.pathCookie path.secureTrue if cookie is secure.httpOnlyTrue if cookie is http-only.sameSiteCookie SameSite type.expiresCookie expiration date, session cookie if not setpriorityCookie Priority type.samePartyTrue if cookie is SameParty.sourceSchemeCookie source scheme type.sourcePortCookie 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.partitionKeyCookie 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.
cookiesCookies to be set. -
setExtraHTTPHeaders(
Headers headers) → Future< void> -
Specifies whether to always send extra HTTP headers with the requests from this page.
headersMap 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.
patternsRequests 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.
userAgentUser agent to use.acceptLanguageBrowser langugage to emulate.platformThe platform navigator.platform should return.userAgentMetadataTo be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData -
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