chrome-devtools-kotlin / org.hildan.chrome.devtools.domains.network / NetworkDomain

NetworkDomain

class NetworkDomain

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.

Official doc

Functions

canClearBrowserCache

Tells whether clearing browser cache is supported.

suspend fun canClearBrowserCache(): CanClearBrowserCacheResponse

canClearBrowserCookies

Tells whether clearing browser cookies is supported.

suspend fun canClearBrowserCookies(): CanClearBrowserCookiesResponse

canEmulateNetworkConditions

Tells whether emulation of network conditions is supported.

suspend fun canEmulateNetworkConditions(): CanEmulateNetworkConditionsResponse

clearBrowserCache

Clears browser cache.

suspend fun clearBrowserCache(): Unit

clearBrowserCookies

Clears browser cookies.

suspend fun clearBrowserCookies(): Unit

continueInterceptedRequest

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.

suspend fun continueInterceptedRequest(input: ContinueInterceptedRequestRequest): Unit

dataReceived

Fired when data chunk was received over the network.

fun dataReceived(): Flow<DataReceivedEvent>

deleteCookies

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

suspend fun deleteCookies(input: DeleteCookiesRequest): Unit

disable

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

suspend fun disable(): Unit

emulateNetworkConditions

Activates emulation of network conditions.

suspend fun emulateNetworkConditions(input: EmulateNetworkConditionsRequest): Unit

enable

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

suspend fun enable(input: EnableRequest): Unit

events

Subscribes to all events related to this domain.

fun events(): Flow<NetworkEvent>

eventSourceMessageReceived

Fired when EventSource message is received.

fun eventSourceMessageReceived(): Flow<EventSourceMessageReceivedEvent>

getAllCookies

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

suspend fun getAllCookies(): GetAllCookiesResponse

getCertificate

Returns the DER-encoded certificate.

suspend fun getCertificate(input: GetCertificateRequest): GetCertificateResponse

getCookies

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

suspend fun getCookies(input: GetCookiesRequest): GetCookiesResponse

getRequestPostData

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

suspend fun getRequestPostData(input: GetRequestPostDataRequest): GetRequestPostDataResponse

getResponseBody

Returns content served for the given request.

suspend fun getResponseBody(input: GetResponseBodyRequest): GetResponseBodyResponse

getResponseBodyForInterception

Returns content served for the given currently intercepted request.

suspend fun getResponseBodyForInterception(input: GetResponseBodyForInterceptionRequest): GetResponseBodyForInterceptionResponse

getSecurityIsolationStatus

Returns information about the COEP/COOP isolation status.

suspend fun getSecurityIsolationStatus(input: GetSecurityIsolationStatusRequest): GetSecurityIsolationStatusResponse

loadingFailed

Fired when HTTP request has failed to load.

fun loadingFailed(): Flow<LoadingFailedEvent>

loadingFinished

Fired when HTTP request has finished loading.

fun loadingFinished(): Flow<LoadingFinishedEvent>

loadNetworkResource

Fetches the resource and returns the content.

suspend fun loadNetworkResource(input: LoadNetworkResourceRequest): LoadNetworkResourceResponse

replayXHR

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.

suspend fun replayXHR(input: ReplayXHRRequest): Unit

requestIntercepted

Details of an intercepted HTTP request, which must be either allowed, blocked, modified or mocked. Deprecated, use Fetch.requestPaused instead.

fun requestIntercepted(): Flow<RequestInterceptedEvent>

requestServedFromCache

Fired if request ended up loading from cache.

fun requestServedFromCache(): Flow<RequestServedFromCacheEvent>

requestWillBeSent

Fired when page is about to send HTTP request.

fun requestWillBeSent(): Flow<RequestWillBeSentEvent>

requestWillBeSentExtraInfo

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.

fun requestWillBeSentExtraInfo(): Flow<RequestWillBeSentExtraInfoEvent>

resourceChangedPriority

Fired when resource loading priority is changed

fun resourceChangedPriority(): Flow<ResourceChangedPriorityEvent>

responseReceived

Fired when HTTP response is available.

fun responseReceived(): Flow<ResponseReceivedEvent>

responseReceivedExtraInfo

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.

fun responseReceivedExtraInfo(): Flow<ResponseReceivedExtraInfoEvent>

searchInResponseBody

Searches for given string in response content.

suspend fun searchInResponseBody(input: SearchInResponseBodyRequest): SearchInResponseBodyResponse

setAttachDebugStack

Specifies whether to attach a page script stack id in requests

suspend fun setAttachDebugStack(input: SetAttachDebugStackRequest): Unit

setBlockedURLs

Blocks URLs from loading.

suspend fun setBlockedURLs(input: SetBlockedURLsRequest): Unit

setBypassServiceWorker

Toggles ignoring of service worker for each request.

suspend fun setBypassServiceWorker(input: SetBypassServiceWorkerRequest): Unit

setCacheDisabled

Toggles ignoring cache for each request. If true, cache will not be used.

suspend fun setCacheDisabled(input: SetCacheDisabledRequest): Unit

setCookie

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

suspend fun setCookie(input: SetCookieRequest): SetCookieResponse

setCookies

Sets given cookies.

suspend fun setCookies(input: SetCookiesRequest): Unit

setDataSizeLimitsForTest

For testing.

suspend fun setDataSizeLimitsForTest(input: SetDataSizeLimitsForTestRequest): Unit

setExtraHTTPHeaders

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

suspend fun setExtraHTTPHeaders(input: SetExtraHTTPHeadersRequest): Unit

setRequestInterception

Sets the requests to intercept that match the provided patterns and optionally resource types. Deprecated, please use Fetch.enable instead.

suspend fun setRequestInterception(input: SetRequestInterceptionRequest): Unit

setUserAgentOverride

Allows overriding user agent with the given string.

suspend fun setUserAgentOverride(input: SetUserAgentOverrideRequest): Unit

signedExchangeReceived

Fired when a signed exchange was received over the network

fun signedExchangeReceived(): Flow<SignedExchangeReceivedEvent>

takeResponseBodyForInterceptionAsStream

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.

suspend fun takeResponseBodyForInterceptionAsStream(input: TakeResponseBodyForInterceptionAsStreamRequest): TakeResponseBodyForInterceptionAsStreamResponse

trustTokenOperationDone

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.

fun trustTokenOperationDone(): Flow<TrustTokenOperationDoneEvent>

webSocketClosed

Fired when WebSocket is closed.

fun webSocketClosed(): Flow<WebSocketClosedEvent>

webSocketCreated

Fired upon WebSocket creation.

fun webSocketCreated(): Flow<WebSocketCreatedEvent>

webSocketFrameError

Fired when WebSocket message error occurs.

fun webSocketFrameError(): Flow<WebSocketFrameErrorEvent>

webSocketFrameReceived

Fired when WebSocket message is received.

fun webSocketFrameReceived(): Flow<WebSocketFrameReceivedEvent>

webSocketFrameSent

Fired when WebSocket message is sent.

fun webSocketFrameSent(): Flow<WebSocketFrameSentEvent>

webSocketHandshakeResponseReceived

Fired when WebSocket handshake response becomes available.

fun webSocketHandshakeResponseReceived(): Flow<WebSocketHandshakeResponseReceivedEvent>

webSocketWillSendHandshakeRequest

Fired when WebSocket is about to initiate handshake.

fun webSocketWillSendHandshakeRequest(): Flow<WebSocketWillSendHandshakeRequestEvent>

webTransportClosed

Official doc

fun webTransportClosed(): Flow<WebTransportClosedEvent>

webTransportCreated

Fired upon WebTransport creation.

fun webTransportCreated(): Flow<WebTransportCreatedEvent>