diff --git a/docs/api/puppeteer.httprequest.abort.md b/docs/api/puppeteer.httprequest.abort.md index bf460dae6da..f555f1240e6 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 ed4c782d923..2abe6d25f70 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 50732351830..df860f76736 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 832d430deeb..b04b26c3916 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 092dfd1f418..82b2a566f9a 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 8d88997500b..973f79a7788 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 3245e3ce3ce..661e16310e9 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 f32e9cfbb01..8e483c1696a 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 6c0a7496787..3b8e22a6ced 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 cd98a3fa67a..3462e19ab69 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 2adca7ac17b..524104e5e6c 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 2807a9cfb16..31403fa967f 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 cfb120e2bc5..381913f9408 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 500d4c10e4e..6e9192b9c30 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 ce261ac28ff..077211da5f3 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 7b7e1b328d5..fda9bd92f07 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 be898d76376..1264d537347 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 dab901feb62..e39001a1d08 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 fa9332ca958..d910d2a057f 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 57a193bb74e..d4bcf659447 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 168b83131b1..581b6c24534 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 ec8e667fa5f..22889e7a06f 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 75c64d4ac67..72c646b62a9 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 781736cd29b..b37a4994cb4 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 ec38a9ebb44..fd4531d7db8 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 7de43d3c17a..67582392b4b 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 05790794ffd..85b24c89b6d 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 411b48c7cff..84fe3d78500 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 fb34ae9eb09..5656a550c1a 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 aeb88988dbc..530adc7008d 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 d8f086d9fa8..d715814d6c8 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 fcb0ab1e1b6..952a27b67e0 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 30449231460..fd833ab7950 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 273d14c395b..64c00ea1671 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 01dbb6c3853..d2b1f16494d 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 65e8c922ff3..7f699dcc056 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 f13e725ee84..e82bc261476 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 af187900187..8d123c4ad07 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 7555877f112..e4c7956dc61 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 754df5242f9..6b4cea40ce6 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 926450c677e..471b9ef1f2a 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 499c260cba4..db840ecdd5c 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);