/** * @fileoverview `NetworkRequest` represents a single network request and keeps * track of all the related CDP events. */ import type { Protocol } from 'devtools-protocol'; import type { CdpClient } from '../../../cdp/CdpClient.js'; import { Network } from '../../../protocol/protocol.js'; import { Deferred } from '../../../utils/Deferred.js'; import { type LoggerFn } from '../../../utils/log.js'; import type { CdpTarget } from '../cdp/CdpTarget.js'; import type { EventManager } from '../session/EventManager.js'; import type { NetworkStorage } from './NetworkStorage.js'; /** Abstracts one individual network request. */ export declare class NetworkRequest { #private; static unknownParameter: string; waitNextPhase: Deferred; constructor(id: Network.Request, eventManager: EventManager, networkStorage: NetworkStorage, cdpTarget: CdpTarget, redirectCount?: number, logger?: LoggerFn, previousHop?: NetworkRequest); get isFinished(): boolean; get finishedPromise(): Promise; get hasResponse(): boolean; get id(): string; get fetchId(): string | undefined; /** * When blocked returns the phase for it */ get interceptPhase(): Network.InterceptPhase | undefined; get url(): string; get redirectCount(): number; get cdpTarget(): CdpTarget; /** CdpTarget can be changed when frame is moving out of process. */ updateCdpTarget(cdpTarget: CdpTarget): void; get cdpClient(): CdpClient; isRedirecting(): boolean; /** * True if the next redirect hop must delay its events after the events of * this hop. This occurs while this hop or a previous hop waits for ExtraInfo * events. */ get delaysNextHop(): boolean; /** * CDP can send the ExtraInfo events of a redirected hop after the * `Network.requestWillBeSent` event of the next hop. All hops have the same * request ID. * * CDP sends the ExtraInfo events of one request in hop order: request(A), * response(A), request(B), response(B), and so on. All of them come from * the same `URLLoader` in the network service through one * `NetworkServiceDevToolsObserver` mojo pipe, and one pipe keeps the message * order. `Network.requestWillBeSent` and `redirectResponse` use a different * path, so they can arrive before the ExtraInfo events of previous hops. * The lag can be longer than one hop. * * Thus, the oldest hop that waits for an ExtraInfo event of the given kind * gets it. If no previous hop waits for it, this hop gets it. */ getHopForExtraInfo(kind: 'request' | 'response'): NetworkRequest; /** * Returns true if the event is the late redirect response ExtraInfo of a * previous hop that stopped waiting for it. Consumes the expected entry. * CDP sends the ExtraInfo events in hop order, so the late events come * before the ExtraInfo of the hops that still wait. */ skipsLateRedirectResponseExtraInfo(event: Protocol.Network.ResponseReceivedExtraInfoEvent): boolean; get bodySize(): number; handleRedirect(event: Protocol.Network.RequestWillBeSentEvent): void; onRequestWillBeSentEvent(event: Protocol.Network.RequestWillBeSentEvent): void; onRequestWillBeSentExtraInfoEvent(event: Protocol.Network.RequestWillBeSentExtraInfoEvent): void; onResponseReceivedExtraInfoEvent(event: Protocol.Network.ResponseReceivedExtraInfoEvent): void; onResponseReceivedEvent(event: Protocol.Network.ResponseReceivedEvent): void; onServedFromCache(): void; onLoadingFinishedEvent(event: Protocol.Network.LoadingFinishedEvent): void; onDataReceivedEvent(event: Protocol.Network.DataReceivedEvent): void; onLoadingFailedEvent(event: Protocol.Network.LoadingFailedEvent): void; /** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-failRequest */ failRequest(errorReason: Protocol.Network.ErrorReason): Promise; onRequestPaused(event: Protocol.Fetch.RequestPausedEvent): void; onAuthRequired(event: Protocol.Fetch.AuthRequiredEvent): void; /** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueRequest */ continueRequest(overrides?: Omit): Promise; /** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueResponse */ continueResponse(overrides?: Omit): Promise; /** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueWithAuth */ continueWithAuth(authChallenge: Omit): Promise; /** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-provideResponse */ provideResponse(overrides: Omit): Promise; dispose(): void; disposeData(): void; get encodedResponseBodySize(): number | null; get responseBytesReceived(): number; get decodedResponseBodySize(): number; }