diff --git a/docs/api/puppeteer.httprequest.abort.md b/docs/api/puppeteer.httprequest.abort.md index bf460dae..f555f124 100644 --- a/docs/api/puppeteer.httprequest.abort.md +++ b/docs/api/puppeteer.httprequest.abort.md @@ -10,7 +10,7 @@ Aborts a request. ```typescript class HTTPRequest { - abort(errorCode?: ErrorCode, priority?: number): Promise; + abstract abort(errorCode?: ErrorCode, priority?: number): Promise; } ``` diff --git a/docs/api/puppeteer.httprequest.aborterrorreason.md b/docs/api/puppeteer.httprequest.aborterrorreason.md index ed4c782d..2abe6d25 100644 --- a/docs/api/puppeteer.httprequest.aborterrorreason.md +++ b/docs/api/puppeteer.httprequest.aborterrorreason.md @@ -10,7 +10,7 @@ The most recent reason for aborting the request ```typescript class HTTPRequest { - abortErrorReason(): Protocol.Network.ErrorReason | null; + abstract abortErrorReason(): Protocol.Network.ErrorReason | null; } ``` diff --git a/docs/api/puppeteer.httprequest.continue.md b/docs/api/puppeteer.httprequest.continue.md index 50732351..df860f76 100644 --- a/docs/api/puppeteer.httprequest.continue.md +++ b/docs/api/puppeteer.httprequest.continue.md @@ -10,7 +10,7 @@ Continues request with optional request overrides. ```typescript class HTTPRequest { - continue( + abstract continue( overrides?: ContinueRequestOverrides, priority?: number ): Promise; diff --git a/docs/api/puppeteer.httprequest.continuerequestoverrides.md b/docs/api/puppeteer.httprequest.continuerequestoverrides.md index 832d430d..b04b26c3 100644 --- a/docs/api/puppeteer.httprequest.continuerequestoverrides.md +++ b/docs/api/puppeteer.httprequest.continuerequestoverrides.md @@ -10,7 +10,7 @@ The `ContinueRequestOverrides` that will be used if the interception is allowed ```typescript class HTTPRequest { - continueRequestOverrides(): ContinueRequestOverrides; + abstract continueRequestOverrides(): ContinueRequestOverrides; } ``` diff --git a/docs/api/puppeteer.httprequest.enqueueinterceptaction.md b/docs/api/puppeteer.httprequest.enqueueinterceptaction.md index 092dfd1f..82b2a566 100644 --- a/docs/api/puppeteer.httprequest.enqueueinterceptaction.md +++ b/docs/api/puppeteer.httprequest.enqueueinterceptaction.md @@ -10,7 +10,7 @@ Adds an async request handler to the processing queue. Deferred handlers are not ```typescript class HTTPRequest { - enqueueInterceptAction( + abstract enqueueInterceptAction( pendingHandler: () => void | PromiseLike ): void; } diff --git a/docs/api/puppeteer.httprequest.failure.md b/docs/api/puppeteer.httprequest.failure.md index 8d889975..973f79a7 100644 --- a/docs/api/puppeteer.httprequest.failure.md +++ b/docs/api/puppeteer.httprequest.failure.md @@ -10,7 +10,7 @@ Access information about the request's failure. ```typescript class HTTPRequest { - failure(): { + abstract failure(): { errorText: string; } | null; } diff --git a/docs/api/puppeteer.httprequest.finalizeinterceptions.md b/docs/api/puppeteer.httprequest.finalizeinterceptions.md index 3245e3ce..661e1631 100644 --- a/docs/api/puppeteer.httprequest.finalizeinterceptions.md +++ b/docs/api/puppeteer.httprequest.finalizeinterceptions.md @@ -10,7 +10,7 @@ Awaits pending interception handlers and then decides how to fulfill the request ```typescript class HTTPRequest { - finalizeInterceptions(): Promise; + abstract finalizeInterceptions(): Promise; } ``` diff --git a/docs/api/puppeteer.httprequest.frame.md b/docs/api/puppeteer.httprequest.frame.md index f32e9cfb..8e483c16 100644 --- a/docs/api/puppeteer.httprequest.frame.md +++ b/docs/api/puppeteer.httprequest.frame.md @@ -10,7 +10,7 @@ The frame that initiated the request, or null if navigating to error pages. ```typescript class HTTPRequest { - frame(): Frame | null; + abstract frame(): Frame | null; } ``` diff --git a/docs/api/puppeteer.httprequest.headers.md b/docs/api/puppeteer.httprequest.headers.md index 6c0a7496..3b8e22a6 100644 --- a/docs/api/puppeteer.httprequest.headers.md +++ b/docs/api/puppeteer.httprequest.headers.md @@ -10,7 +10,7 @@ An object with HTTP headers associated with the request. All header names are lo ```typescript class HTTPRequest { - headers(): Record; + abstract headers(): Record; } ``` diff --git a/docs/api/puppeteer.httprequest.initiator.md b/docs/api/puppeteer.httprequest.initiator.md index cd98a3fa..3462e19a 100644 --- a/docs/api/puppeteer.httprequest.initiator.md +++ b/docs/api/puppeteer.httprequest.initiator.md @@ -10,7 +10,7 @@ The initiator of the request. ```typescript class HTTPRequest { - initiator(): Protocol.Network.Initiator | undefined; + abstract initiator(): Protocol.Network.Initiator | undefined; } ``` diff --git a/docs/api/puppeteer.httprequest.interceptresolutionstate.md b/docs/api/puppeteer.httprequest.interceptresolutionstate.md index 2adca7ac..524104e5 100644 --- a/docs/api/puppeteer.httprequest.interceptresolutionstate.md +++ b/docs/api/puppeteer.httprequest.interceptresolutionstate.md @@ -14,7 +14,7 @@ InterceptResolutionAction is one of: `abort`, `respond`, `continue`, `disabled`, ```typescript class HTTPRequest { - interceptResolutionState(): InterceptResolutionState; + abstract interceptResolutionState(): InterceptResolutionState; } ``` diff --git a/docs/api/puppeteer.httprequest.isinterceptresolutionhandled.md b/docs/api/puppeteer.httprequest.isinterceptresolutionhandled.md index 2807a9cf..31403fa9 100644 --- a/docs/api/puppeteer.httprequest.isinterceptresolutionhandled.md +++ b/docs/api/puppeteer.httprequest.isinterceptresolutionhandled.md @@ -10,7 +10,7 @@ Is `true` if the intercept resolution has already been handled, `false` otherwis ```typescript class HTTPRequest { - isInterceptResolutionHandled(): boolean; + abstract isInterceptResolutionHandled(): boolean; } ``` diff --git a/docs/api/puppeteer.httprequest.isnavigationrequest.md b/docs/api/puppeteer.httprequest.isnavigationrequest.md index cfb120e2..381913f9 100644 --- a/docs/api/puppeteer.httprequest.isnavigationrequest.md +++ b/docs/api/puppeteer.httprequest.isnavigationrequest.md @@ -10,7 +10,7 @@ True if the request is the driver of the current frame's navigation. ```typescript class HTTPRequest { - isNavigationRequest(): boolean; + abstract isNavigationRequest(): boolean; } ``` diff --git a/docs/api/puppeteer.httprequest.md b/docs/api/puppeteer.httprequest.md index 500d4c10..6e9192b9 100644 --- a/docs/api/puppeteer.httprequest.md +++ b/docs/api/puppeteer.httprequest.md @@ -9,7 +9,7 @@ Represents an HTTP request sent by a page. #### Signature: ```typescript -export declare class HTTPRequest +export declare abstract class HTTPRequest ``` ## Remarks diff --git a/docs/api/puppeteer.httprequest.method.md b/docs/api/puppeteer.httprequest.method.md index ce261ac2..077211da 100644 --- a/docs/api/puppeteer.httprequest.method.md +++ b/docs/api/puppeteer.httprequest.method.md @@ -10,7 +10,7 @@ The method used (`GET`, `POST`, etc.) ```typescript class HTTPRequest { - method(): string; + abstract method(): string; } ``` diff --git a/docs/api/puppeteer.httprequest.postdata.md b/docs/api/puppeteer.httprequest.postdata.md index 7b7e1b32..fda9bd92 100644 --- a/docs/api/puppeteer.httprequest.postdata.md +++ b/docs/api/puppeteer.httprequest.postdata.md @@ -10,7 +10,7 @@ The request's post body, if any. ```typescript class HTTPRequest { - postData(): string | undefined; + abstract postData(): string | undefined; } ``` diff --git a/docs/api/puppeteer.httprequest.redirectchain.md b/docs/api/puppeteer.httprequest.redirectchain.md index be898d76..1264d537 100644 --- a/docs/api/puppeteer.httprequest.redirectchain.md +++ b/docs/api/puppeteer.httprequest.redirectchain.md @@ -10,7 +10,7 @@ A `redirectChain` is a chain of requests initiated to fetch a resource. ```typescript class HTTPRequest { - redirectChain(): HTTPRequest[]; + abstract redirectChain(): HTTPRequest[]; } ``` diff --git a/docs/api/puppeteer.httprequest.resourcetype.md b/docs/api/puppeteer.httprequest.resourcetype.md index dab901fe..e39001a1 100644 --- a/docs/api/puppeteer.httprequest.resourcetype.md +++ b/docs/api/puppeteer.httprequest.resourcetype.md @@ -10,7 +10,7 @@ Contains the request's resource type as it was perceived by the rendering engine ```typescript class HTTPRequest { - resourceType(): ResourceType; + abstract resourceType(): ResourceType; } ``` diff --git a/docs/api/puppeteer.httprequest.respond.md b/docs/api/puppeteer.httprequest.respond.md index fa9332ca..d910d2a0 100644 --- a/docs/api/puppeteer.httprequest.respond.md +++ b/docs/api/puppeteer.httprequest.respond.md @@ -10,7 +10,7 @@ Fulfills a request with the given response. ```typescript class HTTPRequest { - respond( + abstract respond( response: Partial, priority?: number ): Promise; diff --git a/docs/api/puppeteer.httprequest.response.md b/docs/api/puppeteer.httprequest.response.md index 57a193bb..d4bcf659 100644 --- a/docs/api/puppeteer.httprequest.response.md +++ b/docs/api/puppeteer.httprequest.response.md @@ -10,7 +10,7 @@ A matching `HTTPResponse` object, or null if the response has not been received ```typescript class HTTPRequest { - response(): HTTPResponse | null; + abstract response(): HTTPResponse | null; } ``` diff --git a/docs/api/puppeteer.httprequest.responseforrequest.md b/docs/api/puppeteer.httprequest.responseforrequest.md index 168b8313..581b6c24 100644 --- a/docs/api/puppeteer.httprequest.responseforrequest.md +++ b/docs/api/puppeteer.httprequest.responseforrequest.md @@ -10,7 +10,7 @@ The `ResponseForRequest` that gets used if the interception is allowed to respon ```typescript class HTTPRequest { - responseForRequest(): Partial | null; + abstract responseForRequest(): Partial | null; } ``` diff --git a/docs/api/puppeteer.httprequest.url.md b/docs/api/puppeteer.httprequest.url.md index ec8e667f..22889e7a 100644 --- a/docs/api/puppeteer.httprequest.url.md +++ b/docs/api/puppeteer.httprequest.url.md @@ -10,7 +10,7 @@ The URL of the request ```typescript class HTTPRequest { - url(): string; + abstract url(): string; } ``` diff --git a/docs/api/puppeteer.httpresponse.buffer.md b/docs/api/puppeteer.httpresponse.buffer.md index 75c64d4a..72c646b6 100644 --- a/docs/api/puppeteer.httpresponse.buffer.md +++ b/docs/api/puppeteer.httpresponse.buffer.md @@ -10,7 +10,7 @@ Promise which resolves to a buffer with response body. ```typescript class HTTPResponse { - buffer(): Promise; + abstract buffer(): Promise; } ``` diff --git a/docs/api/puppeteer.httpresponse.frame.md b/docs/api/puppeteer.httpresponse.frame.md index 781736cd..b37a4994 100644 --- a/docs/api/puppeteer.httpresponse.frame.md +++ b/docs/api/puppeteer.httpresponse.frame.md @@ -10,7 +10,7 @@ A [Frame](./puppeteer.frame.md) that initiated this response, or `null` if navig ```typescript class HTTPResponse { - frame(): Frame | null; + abstract frame(): Frame | null; } ``` diff --git a/docs/api/puppeteer.httpresponse.fromcache.md b/docs/api/puppeteer.httpresponse.fromcache.md index ec38a9eb..fd4531d7 100644 --- a/docs/api/puppeteer.httpresponse.fromcache.md +++ b/docs/api/puppeteer.httpresponse.fromcache.md @@ -10,7 +10,7 @@ True if the response was served from either the browser's disk cache or memory c ```typescript class HTTPResponse { - fromCache(): boolean; + abstract fromCache(): boolean; } ``` diff --git a/docs/api/puppeteer.httpresponse.fromserviceworker.md b/docs/api/puppeteer.httpresponse.fromserviceworker.md index 7de43d3c..67582392 100644 --- a/docs/api/puppeteer.httpresponse.fromserviceworker.md +++ b/docs/api/puppeteer.httpresponse.fromserviceworker.md @@ -10,7 +10,7 @@ True if the response was served by a service worker. ```typescript class HTTPResponse { - fromServiceWorker(): boolean; + abstract fromServiceWorker(): boolean; } ``` diff --git a/docs/api/puppeteer.httpresponse.headers.md b/docs/api/puppeteer.httpresponse.headers.md index 05790794..85b24c89 100644 --- a/docs/api/puppeteer.httpresponse.headers.md +++ b/docs/api/puppeteer.httpresponse.headers.md @@ -10,7 +10,7 @@ An object with HTTP headers associated with the response. All header names are l ```typescript class HTTPResponse { - headers(): Record; + abstract headers(): Record; } ``` diff --git a/docs/api/puppeteer.httpresponse.md b/docs/api/puppeteer.httpresponse.md index 411b48c7..84fe3d78 100644 --- a/docs/api/puppeteer.httpresponse.md +++ b/docs/api/puppeteer.httpresponse.md @@ -9,7 +9,7 @@ The HTTPResponse class represents responses which are received by the [Page](./p #### Signature: ```typescript -export declare class HTTPResponse +export declare abstract class HTTPResponse ``` ## Remarks diff --git a/docs/api/puppeteer.httpresponse.remoteaddress.md b/docs/api/puppeteer.httpresponse.remoteaddress.md index fb34ae9e..5656a550 100644 --- a/docs/api/puppeteer.httpresponse.remoteaddress.md +++ b/docs/api/puppeteer.httpresponse.remoteaddress.md @@ -10,7 +10,7 @@ The IP address and port number used to connect to the remote server. ```typescript class HTTPResponse { - remoteAddress(): RemoteAddress; + abstract remoteAddress(): RemoteAddress; } ``` diff --git a/docs/api/puppeteer.httpresponse.request.md b/docs/api/puppeteer.httpresponse.request.md index aeb88988..530adc70 100644 --- a/docs/api/puppeteer.httpresponse.request.md +++ b/docs/api/puppeteer.httpresponse.request.md @@ -10,7 +10,7 @@ A matching [HTTPRequest](./puppeteer.httprequest.md) object. ```typescript class HTTPResponse { - request(): HTTPRequest; + abstract request(): HTTPRequest; } ``` diff --git a/docs/api/puppeteer.httpresponse.securitydetails.md b/docs/api/puppeteer.httpresponse.securitydetails.md index d8f086d9..d715814d 100644 --- a/docs/api/puppeteer.httpresponse.securitydetails.md +++ b/docs/api/puppeteer.httpresponse.securitydetails.md @@ -10,7 +10,7 @@ sidebar_label: HTTPResponse.securityDetails ```typescript class HTTPResponse { - securityDetails(): SecurityDetails | null; + abstract securityDetails(): SecurityDetails | null; } ``` diff --git a/docs/api/puppeteer.httpresponse.status.md b/docs/api/puppeteer.httpresponse.status.md index fcb0ab1e..952a27b6 100644 --- a/docs/api/puppeteer.httpresponse.status.md +++ b/docs/api/puppeteer.httpresponse.status.md @@ -10,7 +10,7 @@ The status code of the response (e.g., 200 for a success). ```typescript class HTTPResponse { - status(): number; + abstract status(): number; } ``` diff --git a/docs/api/puppeteer.httpresponse.statustext.md b/docs/api/puppeteer.httpresponse.statustext.md index 30449231..fd833ab7 100644 --- a/docs/api/puppeteer.httpresponse.statustext.md +++ b/docs/api/puppeteer.httpresponse.statustext.md @@ -10,7 +10,7 @@ The status text of the response (e.g. usually an "OK" for a success). ```typescript class HTTPResponse { - statusText(): string; + abstract statusText(): string; } ``` diff --git a/docs/api/puppeteer.httpresponse.timing.md b/docs/api/puppeteer.httpresponse.timing.md index 273d14c3..64c00ea1 100644 --- a/docs/api/puppeteer.httpresponse.timing.md +++ b/docs/api/puppeteer.httpresponse.timing.md @@ -10,7 +10,7 @@ Timing information related to the response. ```typescript class HTTPResponse { - timing(): Protocol.Network.ResourceTiming | null; + abstract timing(): Protocol.Network.ResourceTiming | null; } ``` diff --git a/docs/api/puppeteer.httpresponse.url.md b/docs/api/puppeteer.httpresponse.url.md index 01dbb6c3..d2b1f164 100644 --- a/docs/api/puppeteer.httpresponse.url.md +++ b/docs/api/puppeteer.httpresponse.url.md @@ -10,7 +10,7 @@ The URL of the response. ```typescript class HTTPResponse { - url(): string; + abstract url(): string; } ``` diff --git a/packages/puppeteer-core/src/api/HTTPRequest.ts b/packages/puppeteer-core/src/api/HTTPRequest.ts index 65e8c922..7f699dcc 100644 --- a/packages/puppeteer-core/src/api/HTTPRequest.ts +++ b/packages/puppeteer-core/src/api/HTTPRequest.ts @@ -100,7 +100,7 @@ export const DEFAULT_INTERCEPT_RESOLUTION_PRIORITY = 0; * * @public */ -export class HTTPRequest { +export abstract class HTTPRequest { /** * @internal */ @@ -131,9 +131,7 @@ export class HTTPRequest { * * @experimental */ - get client(): CDPSession { - throw new Error('Not implemented'); - } + abstract get client(): CDPSession; /** * @internal @@ -143,33 +141,25 @@ export class HTTPRequest { /** * The URL of the request */ - url(): string { - throw new Error('Not implemented'); - } + abstract url(): string; /** * The `ContinueRequestOverrides` that will be used * if the interception is allowed to continue (ie, `abort()` and * `respond()` aren't called). */ - continueRequestOverrides(): ContinueRequestOverrides { - throw new Error('Not implemented'); - } + abstract continueRequestOverrides(): ContinueRequestOverrides; /** * The `ResponseForRequest` that gets used if the * interception is allowed to respond (ie, `abort()` is not called). */ - responseForRequest(): Partial | null { - throw new Error('Not implemented'); - } + abstract responseForRequest(): Partial | null; /** * The most recent reason for aborting the request */ - abortErrorReason(): Protocol.Network.ErrorReason | null { - throw new Error('Not implemented'); - } + abstract abortErrorReason(): Protocol.Network.ErrorReason | null; /** * An InterceptResolutionState object describing the current resolution @@ -182,17 +172,13 @@ export class HTTPRequest { * InterceptResolutionAction is one of: `abort`, `respond`, `continue`, * `disabled`, `none`, or `already-handled`. */ - interceptResolutionState(): InterceptResolutionState { - throw new Error('Not implemented'); - } + abstract interceptResolutionState(): InterceptResolutionState; /** * Is `true` if the intercept resolution has already been handled, * `false` otherwise. */ - isInterceptResolutionHandled(): boolean { - throw new Error('Not implemented'); - } + abstract isInterceptResolutionHandled(): boolean; /** * Adds an async request handler to the processing queue. @@ -200,80 +186,59 @@ export class HTTPRequest { * but they are guaranteed to resolve before the request interception * is finalized. */ - enqueueInterceptAction( + abstract enqueueInterceptAction( pendingHandler: () => void | PromiseLike ): void; - enqueueInterceptAction(): void { - throw new Error('Not implemented'); - } /** * Awaits pending interception handlers and then decides how to fulfill * the request interception. */ - async finalizeInterceptions(): Promise { - throw new Error('Not implemented'); - } + abstract finalizeInterceptions(): Promise; /** * Contains the request's resource type as it was perceived by the rendering * engine. */ - resourceType(): ResourceType { - throw new Error('Not implemented'); - } + abstract resourceType(): ResourceType; /** * The method used (`GET`, `POST`, etc.) */ - method(): string { - throw new Error('Not implemented'); - } + abstract method(): string; /** * The request's post body, if any. */ - postData(): string | undefined { - throw new Error('Not implemented'); - } + abstract postData(): string | undefined; /** * An object with HTTP headers associated with the request. All * header names are lower-case. */ - headers(): Record { - throw new Error('Not implemented'); - } + abstract headers(): Record; /** * A matching `HTTPResponse` object, or null if the response has not * been received yet. */ - response(): HTTPResponse | null { - throw new Error('Not implemented'); - } + abstract response(): HTTPResponse | null; /** * The frame that initiated the request, or null if navigating to * error pages. */ - frame(): Frame | null { - throw new Error('Not implemented'); - } + abstract frame(): Frame | null; /** * True if the request is the driver of the current frame's navigation. */ - isNavigationRequest(): boolean { - throw new Error('Not implemented'); - } + abstract isNavigationRequest(): boolean; /** * The initiator of the request. */ - initiator(): Protocol.Network.Initiator | undefined { - throw new Error('Not implemented'); - } + abstract initiator(): Protocol.Network.Initiator | undefined; /** * A `redirectChain` is a chain of requests initiated to fetch a resource. @@ -302,9 +267,7 @@ export class HTTPRequest { * @returns the chain of requests - if a server responds with at least a * single redirect, this chain will contain all requests that were redirected. */ - redirectChain(): HTTPRequest[] { - throw new Error('Not implemented'); - } + abstract redirectChain(): HTTPRequest[]; /** * Access information about the request's failure. @@ -326,9 +289,7 @@ export class HTTPRequest { * message, e.g. `net::ERR_FAILED`. It is not guaranteed that there will be * failure text if the request fails. */ - failure(): {errorText: string} | null { - throw new Error('Not implemented'); - } + abstract failure(): {errorText: string} | null; /** * Continues request with optional request overrides. @@ -359,13 +320,10 @@ export class HTTPRequest { * cooperative handling rules. Otherwise, intercept is resolved * immediately. */ - async continue( + abstract continue( overrides?: ContinueRequestOverrides, priority?: number ): Promise; - async continue(): Promise { - throw new Error('Not implemented'); - } /** * Fulfills a request with the given response. @@ -399,13 +357,10 @@ export class HTTPRequest { * cooperative handling rules. Otherwise, intercept is resolved * immediately. */ - async respond( + abstract respond( response: Partial, priority?: number ): Promise; - async respond(): Promise { - throw new Error('Not implemented'); - } /** * Aborts a request. @@ -420,10 +375,7 @@ export class HTTPRequest { * cooperative handling rules. Otherwise, intercept is resolved * immediately. */ - async abort(errorCode?: ErrorCode, priority?: number): Promise; - async abort(): Promise { - throw new Error('Not implemented'); - } + abstract abort(errorCode?: ErrorCode, priority?: number): Promise; } /** @@ -499,7 +451,7 @@ export function headersArray( * List taken from {@link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml} * with extra 306 and 418 codes. */ -export const STATUS_TEXTS: Record = { +export const STATUS_TEXTS: Record = { '100': 'Continue', '101': 'Switching Protocols', '102': 'Processing', diff --git a/packages/puppeteer-core/src/api/HTTPResponse.ts b/packages/puppeteer-core/src/api/HTTPResponse.ts index f13e725e..e82bc261 100644 --- a/packages/puppeteer-core/src/api/HTTPResponse.ts +++ b/packages/puppeteer-core/src/api/HTTPResponse.ts @@ -35,33 +35,22 @@ export interface RemoteAddress { * * @public */ -export class HTTPResponse { +export abstract class HTTPResponse { /** * @internal */ constructor() {} - /** - * @internal - */ - _resolveBody(_err: Error | null): void { - throw new Error('Not implemented'); - } - /** * The IP address and port number used to connect to the remote * server. */ - remoteAddress(): RemoteAddress { - throw new Error('Not implemented'); - } + abstract remoteAddress(): RemoteAddress; /** * The URL of the response. */ - url(): string { - throw new Error('Not implemented'); - } + abstract url(): string; /** * True if the response was successful (status in the range 200-299). @@ -75,47 +64,35 @@ export class HTTPResponse { /** * The status code of the response (e.g., 200 for a success). */ - status(): number { - throw new Error('Not implemented'); - } + abstract status(): number; /** * The status text of the response (e.g. usually an "OK" for a * success). */ - statusText(): string { - throw new Error('Not implemented'); - } + abstract statusText(): string; /** * An object with HTTP headers associated with the response. All * header names are lower-case. */ - headers(): Record { - throw new Error('Not implemented'); - } + abstract headers(): Record; /** * {@link SecurityDetails} if the response was received over the * secure connection, or `null` otherwise. */ - securityDetails(): SecurityDetails | null { - throw new Error('Not implemented'); - } + abstract securityDetails(): SecurityDetails | null; /** * Timing information related to the response. */ - timing(): Protocol.Network.ResourceTiming | null { - throw new Error('Not implemented'); - } + abstract timing(): Protocol.Network.ResourceTiming | null; /** * Promise which resolves to a buffer with response body. */ - buffer(): Promise { - throw new Error('Not implemented'); - } + abstract buffer(): Promise; /** * Promise which resolves to a text representation of response body. @@ -141,30 +118,22 @@ export class HTTPResponse { /** * A matching {@link HTTPRequest} object. */ - request(): HTTPRequest { - throw new Error('Not implemented'); - } + abstract request(): HTTPRequest; /** * True if the response was served from either the browser's disk * cache or memory cache. */ - fromCache(): boolean { - throw new Error('Not implemented'); - } + abstract fromCache(): boolean; /** * True if the response was served by a service worker. */ - fromServiceWorker(): boolean { - throw new Error('Not implemented'); - } + abstract fromServiceWorker(): boolean; /** * A {@link Frame} that initiated this response, or `null` if * navigating to error pages. */ - frame(): Frame | null { - throw new Error('Not implemented'); - } + abstract frame(): Frame | null; } diff --git a/packages/puppeteer-core/src/bidi/HTTPRequest.ts b/packages/puppeteer-core/src/bidi/HTTPRequest.ts index af187900..8d123c4a 100644 --- a/packages/puppeteer-core/src/bidi/HTTPRequest.ts +++ b/packages/puppeteer-core/src/bidi/HTTPRequest.ts @@ -14,9 +14,16 @@ * limitations under the License. */ import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js'; +import type {Protocol} from 'devtools-protocol'; import type {Frame} from '../api/Frame.js'; +import type { + ContinueRequestOverrides, + InterceptResolutionState, + ResponseForRequest, +} from '../api/HTTPRequest.js'; import {HTTPRequest, type ResourceType} from '../api/HTTPRequest.js'; +import type {CDPSession} from '../puppeteer-core.js'; import type {BidiHTTPResponse} from './HTTPResponse.js'; @@ -64,6 +71,10 @@ export class BidiHTTPRequest extends HTTPRequest { } } + override get client(): CDPSession { + throw new Error('Not implemented'); + } + override url(): string { return this.#url; } @@ -110,4 +121,49 @@ export class BidiHTTPRequest extends HTTPRequest { override frame(): Frame | null { return this.#frame; } + + override continueRequestOverrides(): ContinueRequestOverrides { + throw new Error('Not implemented'); + } + + override async continue( + _overrides: ContinueRequestOverrides = {} + ): Promise { + throw new Error('Not implemented'); + } + + override responseForRequest(): Partial { + throw new Error('Not implemented'); + } + + override abortErrorReason(): Protocol.Network.ErrorReason | null { + throw new Error('Not implemented'); + } + + override interceptResolutionState(): InterceptResolutionState { + throw new Error('Not implemented'); + } + + override isInterceptResolutionHandled(): boolean { + throw new Error('Not implemented'); + } + + override async finalizeInterceptions(): Promise { + throw new Error('Not implemented'); + } + + override abort(): Promise { + throw new Error('Not implemented'); + } + + override respond( + _response: Partial, + _priority?: number + ): Promise { + throw new Error('Not implemented'); + } + + override failure(): {errorText: string} | null { + throw new Error('Not implemented'); + } } diff --git a/packages/puppeteer-core/src/bidi/HTTPResponse.ts b/packages/puppeteer-core/src/bidi/HTTPResponse.ts index 7555877f..e4c7956d 100644 --- a/packages/puppeteer-core/src/bidi/HTTPResponse.ts +++ b/packages/puppeteer-core/src/bidi/HTTPResponse.ts @@ -21,6 +21,7 @@ import { HTTPResponse as HTTPResponse, type RemoteAddress, } from '../api/HTTPResponse.js'; +import type {SecurityDetails} from '../common/SecurityDetails.js'; import type {BidiHTTPRequest} from './HTTPRequest.js'; @@ -105,4 +106,12 @@ export class BidiHTTPResponse extends HTTPResponse { override fromServiceWorker(): boolean { return false; } + + override securityDetails(): SecurityDetails | null { + throw new Error('Not implemented'); + } + + override buffer(): Promise { + throw new Error('Not implemented'); + } } diff --git a/packages/puppeteer-core/src/cdp/HTTPRequest.ts b/packages/puppeteer-core/src/cdp/HTTPRequest.ts index 754df524..6b4cea40 100644 --- a/packages/puppeteer-core/src/cdp/HTTPRequest.ts +++ b/packages/puppeteer-core/src/cdp/HTTPRequest.ts @@ -153,7 +153,7 @@ export class CdpHTTPRequest extends HTTPRequest { return this.#interceptionHandled; } - override enqueueInterceptAction( + enqueueInterceptAction( pendingHandler: () => void | PromiseLike ): void { this.#interceptHandlers.push(pendingHandler); diff --git a/packages/puppeteer-core/src/cdp/HTTPResponse.ts b/packages/puppeteer-core/src/cdp/HTTPResponse.ts index 926450c6..471b9ef1 100644 --- a/packages/puppeteer-core/src/cdp/HTTPResponse.ts +++ b/packages/puppeteer-core/src/cdp/HTTPResponse.ts @@ -31,7 +31,7 @@ export class CdpHTTPResponse extends HTTPResponse { #client: CDPSession; #request: CdpHTTPRequest; #contentPromise: Promise | null = null; - #bodyLoadedDeferred = Deferred.create(); + #bodyLoadedDeferred = Deferred.create(); #remoteAddress: RemoteAddress; #status: number; #statusText: string; @@ -96,9 +96,9 @@ export class CdpHTTPResponse extends HTTPResponse { return statusText; } - override _resolveBody(err: Error | null): void { + _resolveBody(err?: Error): void { if (err) { - return this.#bodyLoadedDeferred.resolve(err); + return this.#bodyLoadedDeferred.reject(err); } return this.#bodyLoadedDeferred.resolve(); } @@ -135,10 +135,7 @@ export class CdpHTTPResponse extends HTTPResponse { if (!this.#contentPromise) { this.#contentPromise = this.#bodyLoadedDeferred .valueOrThrow() - .then(async error => { - if (error) { - throw error; - } + .then(async () => { try { const response = await this.#client.send( 'Network.getResponseBody', diff --git a/packages/puppeteer-core/src/cdp/NetworkManager.ts b/packages/puppeteer-core/src/cdp/NetworkManager.ts index 499c260c..db840ecd 100644 --- a/packages/puppeteer-core/src/cdp/NetworkManager.ts +++ b/packages/puppeteer-core/src/cdp/NetworkManager.ts @@ -680,7 +680,7 @@ export class NetworkManager extends EventEmitter { // Under certain conditions we never get the Network.responseReceived // event from protocol. @see https://crbug.com/883475 if (request.response()) { - request.response()?._resolveBody(null); + request.response()?._resolveBody(); } this.#forgetRequest(request, true); this.emit(NetworkManagerEvent.RequestFinished, request); @@ -712,7 +712,7 @@ export class NetworkManager extends EventEmitter { request._failureText = event.errorText; const response = request.response(); if (response) { - response._resolveBody(null); + response._resolveBody(); } this.#forgetRequest(request, true); this.emit(NetworkManagerEvent.RequestFailed, request);