refactor: rename _requestId to id (#11850)

Co-authored-by: Alex Rudenko <OrKoN@users.noreply.github.com>
This commit is contained in:
jrandolf 2024-02-06 17:42:25 +01:00 committed by GitHub
parent 27c71a9cf6
commit 6c5b9ad3b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 12 additions and 9 deletions

View File

@ -94,7 +94,8 @@ export abstract class HTTPRequest {
/** /**
* @internal * @internal
*/ */
_requestId = ''; abstract get id(): string;
/** /**
* @internal * @internal
*/ */

View File

@ -616,7 +616,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
) )
).pipe( ).pipe(
filter(request => { filter(request => {
return request._requestId === originalRequest._requestId; return request.id === originalRequest.id;
}), }),
take(1), take(1),
map(() => { map(() => {

View File

@ -19,6 +19,7 @@ import type {BidiHTTPResponse} from './HTTPResponse.js';
* @internal * @internal
*/ */
export class BidiHTTPRequest extends HTTPRequest { export class BidiHTTPRequest extends HTTPRequest {
override id: string;
override _response: BidiHTTPResponse | null = null; override _response: BidiHTTPResponse | null = null;
override _redirectChain: BidiHTTPRequest[]; override _redirectChain: BidiHTTPRequest[];
_navigationId: string | null; _navigationId: string | null;
@ -46,7 +47,7 @@ export class BidiHTTPRequest extends HTTPRequest {
this.#initiator = event.initiator; this.#initiator = event.initiator;
this.#frame = frame; this.#frame = frame;
this._requestId = event.request.request; this.id = event.request.request;
this._redirectChain = redirectChain; this._redirectChain = redirectChain;
this._navigationId = event.navigation; this._navigationId = event.navigation;

View File

@ -28,6 +28,7 @@ import type {CdpHTTPResponse} from './HTTPResponse.js';
* @internal * @internal
*/ */
export class CdpHTTPRequest extends HTTPRequest { export class CdpHTTPRequest extends HTTPRequest {
override id: string;
declare _redirectChain: CdpHTTPRequest[]; declare _redirectChain: CdpHTTPRequest[];
declare _response: CdpHTTPResponse | null; declare _response: CdpHTTPResponse | null;
@ -91,7 +92,7 @@ export class CdpHTTPRequest extends HTTPRequest {
) { ) {
super(); super();
this.#client = client; this.#client = client;
this._requestId = data.requestId; this.id = data.requestId;
this.#isNavigationRequest = this.#isNavigationRequest =
data.requestId === data.loaderId && data.type === 'Document'; data.requestId === data.loaderId && data.type === 'Document';
this._interceptionId = interceptionId; this._interceptionId = interceptionId;
@ -188,7 +189,7 @@ export class CdpHTTPRequest extends HTTPRequest {
override async fetchPostData(): Promise<string | undefined> { override async fetchPostData(): Promise<string | undefined> {
try { try {
const result = await this.#client.send('Network.getRequestPostData', { const result = await this.#client.send('Network.getRequestPostData', {
requestId: this._requestId, requestId: this.id,
}); });
return result.postData; return result.postData;
} catch (err) { } catch (err) {

View File

@ -130,7 +130,7 @@ export class CdpHTTPResponse extends HTTPResponse {
const response = await this.#client.send( const response = await this.#client.send(
'Network.getResponseBody', 'Network.getResponseBody',
{ {
requestId: this.#request._requestId, requestId: this.#request.id,
} }
); );
return Buffer.from( return Buffer.from(

View File

@ -191,14 +191,14 @@ export class LifecycleWatcher {
} }
#onRequestFailed(request: HTTPRequest): void { #onRequestFailed(request: HTTPRequest): void {
if (this.#navigationRequest?._requestId !== request._requestId) { if (this.#navigationRequest?.id !== request.id) {
return; return;
} }
this.#navigationResponseReceived?.resolve(); this.#navigationResponseReceived?.resolve();
} }
#onResponse(response: HTTPResponse): void { #onResponse(response: HTTPResponse): void {
if (this.#navigationRequest?._requestId !== response.request()._requestId) { if (this.#navigationRequest?.id !== response.request().id) {
return; return;
} }
this.#navigationResponseReceived?.resolve(); this.#navigationResponseReceived?.resolve();

View File

@ -637,7 +637,7 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
} }
#forgetRequest(request: CdpHTTPRequest, events: boolean): void { #forgetRequest(request: CdpHTTPRequest, events: boolean): void {
const requestId = request._requestId; const requestId = request.id;
const interceptionId = request._interceptionId; const interceptionId = request._interceptionId;
this.#networkEventManager.forgetRequest(requestId); this.#networkEventManager.forgetRequest(requestId);