mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: use abstract for HTTP classes (#11300)
This commit is contained in:
parent
76434112ac
commit
47e708b979
@ -10,7 +10,7 @@ Aborts a request.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
abort(errorCode?: ErrorCode, priority?: number): Promise<void>;
|
abstract abort(errorCode?: ErrorCode, priority?: number): Promise<void>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ The most recent reason for aborting the request
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
abortErrorReason(): Protocol.Network.ErrorReason | null;
|
abstract abortErrorReason(): Protocol.Network.ErrorReason | null;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ Continues request with optional request overrides.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
continue(
|
abstract continue(
|
||||||
overrides?: ContinueRequestOverrides,
|
overrides?: ContinueRequestOverrides,
|
||||||
priority?: number
|
priority?: number
|
||||||
): Promise<void>;
|
): Promise<void>;
|
||||||
|
@ -10,7 +10,7 @@ The `ContinueRequestOverrides` that will be used if the interception is allowed
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
continueRequestOverrides(): ContinueRequestOverrides;
|
abstract continueRequestOverrides(): ContinueRequestOverrides;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ Adds an async request handler to the processing queue. Deferred handlers are not
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
enqueueInterceptAction(
|
abstract enqueueInterceptAction(
|
||||||
pendingHandler: () => void | PromiseLike<unknown>
|
pendingHandler: () => void | PromiseLike<unknown>
|
||||||
): void;
|
): void;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ Access information about the request's failure.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
failure(): {
|
abstract failure(): {
|
||||||
errorText: string;
|
errorText: string;
|
||||||
} | null;
|
} | null;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ Awaits pending interception handlers and then decides how to fulfill the request
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
finalizeInterceptions(): Promise<void>;
|
abstract finalizeInterceptions(): Promise<void>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ The frame that initiated the request, or null if navigating to error pages.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
frame(): Frame | null;
|
abstract frame(): Frame | null;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ An object with HTTP headers associated with the request. All header names are lo
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
headers(): Record<string, string>;
|
abstract headers(): Record<string, string>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ The initiator of the request.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
initiator(): Protocol.Network.Initiator | undefined;
|
abstract initiator(): Protocol.Network.Initiator | undefined;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ InterceptResolutionAction is one of: `abort`, `respond`, `continue`, `disabled`,
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
interceptResolutionState(): InterceptResolutionState;
|
abstract interceptResolutionState(): InterceptResolutionState;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ Is `true` if the intercept resolution has already been handled, `false` otherwis
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
isInterceptResolutionHandled(): boolean;
|
abstract isInterceptResolutionHandled(): boolean;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ True if the request is the driver of the current frame's navigation.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
isNavigationRequest(): boolean;
|
abstract isNavigationRequest(): boolean;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Represents an HTTP request sent by a page.
|
|||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export declare class HTTPRequest
|
export declare abstract class HTTPRequest
|
||||||
```
|
```
|
||||||
|
|
||||||
## Remarks
|
## Remarks
|
||||||
|
@ -10,7 +10,7 @@ The method used (`GET`, `POST`, etc.)
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
method(): string;
|
abstract method(): string;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ The request's post body, if any.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
postData(): string | undefined;
|
abstract postData(): string | undefined;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ A `redirectChain` is a chain of requests initiated to fetch a resource.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
redirectChain(): HTTPRequest[];
|
abstract redirectChain(): HTTPRequest[];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ Contains the request's resource type as it was perceived by the rendering engine
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
resourceType(): ResourceType;
|
abstract resourceType(): ResourceType;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ Fulfills a request with the given response.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
respond(
|
abstract respond(
|
||||||
response: Partial<ResponseForRequest>,
|
response: Partial<ResponseForRequest>,
|
||||||
priority?: number
|
priority?: number
|
||||||
): Promise<void>;
|
): Promise<void>;
|
||||||
|
@ -10,7 +10,7 @@ A matching `HTTPResponse` object, or null if the response has not been received
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
response(): HTTPResponse | null;
|
abstract response(): HTTPResponse | null;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ The `ResponseForRequest` that gets used if the interception is allowed to respon
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
responseForRequest(): Partial<ResponseForRequest> | null;
|
abstract responseForRequest(): Partial<ResponseForRequest> | null;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ The URL of the request
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPRequest {
|
class HTTPRequest {
|
||||||
url(): string;
|
abstract url(): string;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ Promise which resolves to a buffer with response body.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
buffer(): Promise<Buffer>;
|
abstract buffer(): Promise<Buffer>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ A [Frame](./puppeteer.frame.md) that initiated this response, or `null` if navig
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
frame(): Frame | null;
|
abstract frame(): Frame | null;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ True if the response was served from either the browser's disk cache or memory c
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
fromCache(): boolean;
|
abstract fromCache(): boolean;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ True if the response was served by a service worker.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
fromServiceWorker(): boolean;
|
abstract fromServiceWorker(): boolean;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ An object with HTTP headers associated with the response. All header names are l
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
headers(): Record<string, string>;
|
abstract headers(): Record<string, string>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ The HTTPResponse class represents responses which are received by the [Page](./p
|
|||||||
#### Signature:
|
#### Signature:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export declare class HTTPResponse
|
export declare abstract class HTTPResponse
|
||||||
```
|
```
|
||||||
|
|
||||||
## Remarks
|
## Remarks
|
||||||
|
@ -10,7 +10,7 @@ The IP address and port number used to connect to the remote server.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
remoteAddress(): RemoteAddress;
|
abstract remoteAddress(): RemoteAddress;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ A matching [HTTPRequest](./puppeteer.httprequest.md) object.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
request(): HTTPRequest;
|
abstract request(): HTTPRequest;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ sidebar_label: HTTPResponse.securityDetails
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
securityDetails(): SecurityDetails | null;
|
abstract securityDetails(): SecurityDetails | null;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ The status code of the response (e.g., 200 for a success).
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
status(): number;
|
abstract status(): number;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ The status text of the response (e.g. usually an "OK" for a success).
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
statusText(): string;
|
abstract statusText(): string;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ Timing information related to the response.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
timing(): Protocol.Network.ResourceTiming | null;
|
abstract timing(): Protocol.Network.ResourceTiming | null;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ The URL of the response.
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class HTTPResponse {
|
class HTTPResponse {
|
||||||
url(): string;
|
abstract url(): string;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ export const DEFAULT_INTERCEPT_RESOLUTION_PRIORITY = 0;
|
|||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export class HTTPRequest {
|
export abstract class HTTPRequest {
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@ -131,9 +131,7 @@ export class HTTPRequest {
|
|||||||
*
|
*
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
get client(): CDPSession {
|
abstract get client(): CDPSession;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -143,33 +141,25 @@ export class HTTPRequest {
|
|||||||
/**
|
/**
|
||||||
* The URL of the request
|
* The URL of the request
|
||||||
*/
|
*/
|
||||||
url(): string {
|
abstract url(): string;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `ContinueRequestOverrides` that will be used
|
* The `ContinueRequestOverrides` that will be used
|
||||||
* if the interception is allowed to continue (ie, `abort()` and
|
* if the interception is allowed to continue (ie, `abort()` and
|
||||||
* `respond()` aren't called).
|
* `respond()` aren't called).
|
||||||
*/
|
*/
|
||||||
continueRequestOverrides(): ContinueRequestOverrides {
|
abstract continueRequestOverrides(): ContinueRequestOverrides;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `ResponseForRequest` that gets used if the
|
* The `ResponseForRequest` that gets used if the
|
||||||
* interception is allowed to respond (ie, `abort()` is not called).
|
* interception is allowed to respond (ie, `abort()` is not called).
|
||||||
*/
|
*/
|
||||||
responseForRequest(): Partial<ResponseForRequest> | null {
|
abstract responseForRequest(): Partial<ResponseForRequest> | null;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The most recent reason for aborting the request
|
* The most recent reason for aborting the request
|
||||||
*/
|
*/
|
||||||
abortErrorReason(): Protocol.Network.ErrorReason | null {
|
abstract abortErrorReason(): Protocol.Network.ErrorReason | null;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An InterceptResolutionState object describing the current resolution
|
* An InterceptResolutionState object describing the current resolution
|
||||||
@ -182,17 +172,13 @@ export class HTTPRequest {
|
|||||||
* InterceptResolutionAction is one of: `abort`, `respond`, `continue`,
|
* InterceptResolutionAction is one of: `abort`, `respond`, `continue`,
|
||||||
* `disabled`, `none`, or `already-handled`.
|
* `disabled`, `none`, or `already-handled`.
|
||||||
*/
|
*/
|
||||||
interceptResolutionState(): InterceptResolutionState {
|
abstract interceptResolutionState(): InterceptResolutionState;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is `true` if the intercept resolution has already been handled,
|
* Is `true` if the intercept resolution has already been handled,
|
||||||
* `false` otherwise.
|
* `false` otherwise.
|
||||||
*/
|
*/
|
||||||
isInterceptResolutionHandled(): boolean {
|
abstract isInterceptResolutionHandled(): boolean;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an async request handler to the processing queue.
|
* 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
|
* but they are guaranteed to resolve before the request interception
|
||||||
* is finalized.
|
* is finalized.
|
||||||
*/
|
*/
|
||||||
enqueueInterceptAction(
|
abstract enqueueInterceptAction(
|
||||||
pendingHandler: () => void | PromiseLike<unknown>
|
pendingHandler: () => void | PromiseLike<unknown>
|
||||||
): void;
|
): void;
|
||||||
enqueueInterceptAction(): void {
|
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Awaits pending interception handlers and then decides how to fulfill
|
* Awaits pending interception handlers and then decides how to fulfill
|
||||||
* the request interception.
|
* the request interception.
|
||||||
*/
|
*/
|
||||||
async finalizeInterceptions(): Promise<void> {
|
abstract finalizeInterceptions(): Promise<void>;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains the request's resource type as it was perceived by the rendering
|
* Contains the request's resource type as it was perceived by the rendering
|
||||||
* engine.
|
* engine.
|
||||||
*/
|
*/
|
||||||
resourceType(): ResourceType {
|
abstract resourceType(): ResourceType;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method used (`GET`, `POST`, etc.)
|
* The method used (`GET`, `POST`, etc.)
|
||||||
*/
|
*/
|
||||||
method(): string {
|
abstract method(): string;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The request's post body, if any.
|
* The request's post body, if any.
|
||||||
*/
|
*/
|
||||||
postData(): string | undefined {
|
abstract postData(): string | undefined;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object with HTTP headers associated with the request. All
|
* An object with HTTP headers associated with the request. All
|
||||||
* header names are lower-case.
|
* header names are lower-case.
|
||||||
*/
|
*/
|
||||||
headers(): Record<string, string> {
|
abstract headers(): Record<string, string>;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A matching `HTTPResponse` object, or null if the response has not
|
* A matching `HTTPResponse` object, or null if the response has not
|
||||||
* been received yet.
|
* been received yet.
|
||||||
*/
|
*/
|
||||||
response(): HTTPResponse | null {
|
abstract response(): HTTPResponse | null;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The frame that initiated the request, or null if navigating to
|
* The frame that initiated the request, or null if navigating to
|
||||||
* error pages.
|
* error pages.
|
||||||
*/
|
*/
|
||||||
frame(): Frame | null {
|
abstract frame(): Frame | null;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the request is the driver of the current frame's navigation.
|
* True if the request is the driver of the current frame's navigation.
|
||||||
*/
|
*/
|
||||||
isNavigationRequest(): boolean {
|
abstract isNavigationRequest(): boolean;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The initiator of the request.
|
* The initiator of the request.
|
||||||
*/
|
*/
|
||||||
initiator(): Protocol.Network.Initiator | undefined {
|
abstract initiator(): Protocol.Network.Initiator | undefined;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A `redirectChain` is a chain of requests initiated to fetch a resource.
|
* 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
|
* @returns the chain of requests - if a server responds with at least a
|
||||||
* single redirect, this chain will contain all requests that were redirected.
|
* single redirect, this chain will contain all requests that were redirected.
|
||||||
*/
|
*/
|
||||||
redirectChain(): HTTPRequest[] {
|
abstract redirectChain(): HTTPRequest[];
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access information about the request's failure.
|
* 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
|
* message, e.g. `net::ERR_FAILED`. It is not guaranteed that there will be
|
||||||
* failure text if the request fails.
|
* failure text if the request fails.
|
||||||
*/
|
*/
|
||||||
failure(): {errorText: string} | null {
|
abstract failure(): {errorText: string} | null;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Continues request with optional request overrides.
|
* Continues request with optional request overrides.
|
||||||
@ -359,13 +320,10 @@ export class HTTPRequest {
|
|||||||
* cooperative handling rules. Otherwise, intercept is resolved
|
* cooperative handling rules. Otherwise, intercept is resolved
|
||||||
* immediately.
|
* immediately.
|
||||||
*/
|
*/
|
||||||
async continue(
|
abstract continue(
|
||||||
overrides?: ContinueRequestOverrides,
|
overrides?: ContinueRequestOverrides,
|
||||||
priority?: number
|
priority?: number
|
||||||
): Promise<void>;
|
): Promise<void>;
|
||||||
async continue(): Promise<void> {
|
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fulfills a request with the given response.
|
* Fulfills a request with the given response.
|
||||||
@ -399,13 +357,10 @@ export class HTTPRequest {
|
|||||||
* cooperative handling rules. Otherwise, intercept is resolved
|
* cooperative handling rules. Otherwise, intercept is resolved
|
||||||
* immediately.
|
* immediately.
|
||||||
*/
|
*/
|
||||||
async respond(
|
abstract respond(
|
||||||
response: Partial<ResponseForRequest>,
|
response: Partial<ResponseForRequest>,
|
||||||
priority?: number
|
priority?: number
|
||||||
): Promise<void>;
|
): Promise<void>;
|
||||||
async respond(): Promise<void> {
|
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aborts a request.
|
* Aborts a request.
|
||||||
@ -420,10 +375,7 @@ export class HTTPRequest {
|
|||||||
* cooperative handling rules. Otherwise, intercept is resolved
|
* cooperative handling rules. Otherwise, intercept is resolved
|
||||||
* immediately.
|
* immediately.
|
||||||
*/
|
*/
|
||||||
async abort(errorCode?: ErrorCode, priority?: number): Promise<void>;
|
abstract abort(errorCode?: ErrorCode, priority?: number): Promise<void>;
|
||||||
async abort(): Promise<void> {
|
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -499,7 +451,7 @@ export function headersArray(
|
|||||||
* List taken from {@link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml}
|
* List taken from {@link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml}
|
||||||
* with extra 306 and 418 codes.
|
* with extra 306 and 418 codes.
|
||||||
*/
|
*/
|
||||||
export const STATUS_TEXTS: Record<string, string | undefined> = {
|
export const STATUS_TEXTS: Record<string, string> = {
|
||||||
'100': 'Continue',
|
'100': 'Continue',
|
||||||
'101': 'Switching Protocols',
|
'101': 'Switching Protocols',
|
||||||
'102': 'Processing',
|
'102': 'Processing',
|
||||||
|
@ -35,33 +35,22 @@ export interface RemoteAddress {
|
|||||||
*
|
*
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export class HTTPResponse {
|
export abstract class HTTPResponse {
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
_resolveBody(_err: Error | null): void {
|
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The IP address and port number used to connect to the remote
|
* The IP address and port number used to connect to the remote
|
||||||
* server.
|
* server.
|
||||||
*/
|
*/
|
||||||
remoteAddress(): RemoteAddress {
|
abstract remoteAddress(): RemoteAddress;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL of the response.
|
* The URL of the response.
|
||||||
*/
|
*/
|
||||||
url(): string {
|
abstract url(): string;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the response was successful (status in the range 200-299).
|
* 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).
|
* The status code of the response (e.g., 200 for a success).
|
||||||
*/
|
*/
|
||||||
status(): number {
|
abstract status(): number;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The status text of the response (e.g. usually an "OK" for a
|
* The status text of the response (e.g. usually an "OK" for a
|
||||||
* success).
|
* success).
|
||||||
*/
|
*/
|
||||||
statusText(): string {
|
abstract statusText(): string;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object with HTTP headers associated with the response. All
|
* An object with HTTP headers associated with the response. All
|
||||||
* header names are lower-case.
|
* header names are lower-case.
|
||||||
*/
|
*/
|
||||||
headers(): Record<string, string> {
|
abstract headers(): Record<string, string>;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link SecurityDetails} if the response was received over the
|
* {@link SecurityDetails} if the response was received over the
|
||||||
* secure connection, or `null` otherwise.
|
* secure connection, or `null` otherwise.
|
||||||
*/
|
*/
|
||||||
securityDetails(): SecurityDetails | null {
|
abstract securityDetails(): SecurityDetails | null;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timing information related to the response.
|
* Timing information related to the response.
|
||||||
*/
|
*/
|
||||||
timing(): Protocol.Network.ResourceTiming | null {
|
abstract timing(): Protocol.Network.ResourceTiming | null;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Promise which resolves to a buffer with response body.
|
* Promise which resolves to a buffer with response body.
|
||||||
*/
|
*/
|
||||||
buffer(): Promise<Buffer> {
|
abstract buffer(): Promise<Buffer>;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Promise which resolves to a text representation of response body.
|
* Promise which resolves to a text representation of response body.
|
||||||
@ -141,30 +118,22 @@ export class HTTPResponse {
|
|||||||
/**
|
/**
|
||||||
* A matching {@link HTTPRequest} object.
|
* A matching {@link HTTPRequest} object.
|
||||||
*/
|
*/
|
||||||
request(): HTTPRequest {
|
abstract request(): HTTPRequest;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the response was served from either the browser's disk
|
* True if the response was served from either the browser's disk
|
||||||
* cache or memory cache.
|
* cache or memory cache.
|
||||||
*/
|
*/
|
||||||
fromCache(): boolean {
|
abstract fromCache(): boolean;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the response was served by a service worker.
|
* True if the response was served by a service worker.
|
||||||
*/
|
*/
|
||||||
fromServiceWorker(): boolean {
|
abstract fromServiceWorker(): boolean;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Frame} that initiated this response, or `null` if
|
* A {@link Frame} that initiated this response, or `null` if
|
||||||
* navigating to error pages.
|
* navigating to error pages.
|
||||||
*/
|
*/
|
||||||
frame(): Frame | null {
|
abstract frame(): Frame | null;
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
|
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 {Frame} from '../api/Frame.js';
|
||||||
|
import type {
|
||||||
|
ContinueRequestOverrides,
|
||||||
|
InterceptResolutionState,
|
||||||
|
ResponseForRequest,
|
||||||
|
} from '../api/HTTPRequest.js';
|
||||||
import {HTTPRequest, type ResourceType} 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';
|
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 {
|
override url(): string {
|
||||||
return this.#url;
|
return this.#url;
|
||||||
}
|
}
|
||||||
@ -110,4 +121,49 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|||||||
override frame(): Frame | null {
|
override frame(): Frame | null {
|
||||||
return this.#frame;
|
return this.#frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override continueRequestOverrides(): ContinueRequestOverrides {
|
||||||
|
throw new Error('Not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
override async continue(
|
||||||
|
_overrides: ContinueRequestOverrides = {}
|
||||||
|
): Promise<void> {
|
||||||
|
throw new Error('Not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
override responseForRequest(): Partial<ResponseForRequest> {
|
||||||
|
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<void> {
|
||||||
|
throw new Error('Not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
override abort(): Promise<void> {
|
||||||
|
throw new Error('Not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
override respond(
|
||||||
|
_response: Partial<ResponseForRequest>,
|
||||||
|
_priority?: number
|
||||||
|
): Promise<void> {
|
||||||
|
throw new Error('Not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
override failure(): {errorText: string} | null {
|
||||||
|
throw new Error('Not implemented');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import {
|
|||||||
HTTPResponse as HTTPResponse,
|
HTTPResponse as HTTPResponse,
|
||||||
type RemoteAddress,
|
type RemoteAddress,
|
||||||
} from '../api/HTTPResponse.js';
|
} from '../api/HTTPResponse.js';
|
||||||
|
import type {SecurityDetails} from '../common/SecurityDetails.js';
|
||||||
|
|
||||||
import type {BidiHTTPRequest} from './HTTPRequest.js';
|
import type {BidiHTTPRequest} from './HTTPRequest.js';
|
||||||
|
|
||||||
@ -105,4 +106,12 @@ export class BidiHTTPResponse extends HTTPResponse {
|
|||||||
override fromServiceWorker(): boolean {
|
override fromServiceWorker(): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override securityDetails(): SecurityDetails | null {
|
||||||
|
throw new Error('Not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
override buffer(): Promise<Buffer> {
|
||||||
|
throw new Error('Not implemented');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ export class CdpHTTPRequest extends HTTPRequest {
|
|||||||
return this.#interceptionHandled;
|
return this.#interceptionHandled;
|
||||||
}
|
}
|
||||||
|
|
||||||
override enqueueInterceptAction(
|
enqueueInterceptAction(
|
||||||
pendingHandler: () => void | PromiseLike<unknown>
|
pendingHandler: () => void | PromiseLike<unknown>
|
||||||
): void {
|
): void {
|
||||||
this.#interceptHandlers.push(pendingHandler);
|
this.#interceptHandlers.push(pendingHandler);
|
||||||
|
@ -31,7 +31,7 @@ export class CdpHTTPResponse extends HTTPResponse {
|
|||||||
#client: CDPSession;
|
#client: CDPSession;
|
||||||
#request: CdpHTTPRequest;
|
#request: CdpHTTPRequest;
|
||||||
#contentPromise: Promise<Buffer> | null = null;
|
#contentPromise: Promise<Buffer> | null = null;
|
||||||
#bodyLoadedDeferred = Deferred.create<Error | void>();
|
#bodyLoadedDeferred = Deferred.create<void, Error>();
|
||||||
#remoteAddress: RemoteAddress;
|
#remoteAddress: RemoteAddress;
|
||||||
#status: number;
|
#status: number;
|
||||||
#statusText: string;
|
#statusText: string;
|
||||||
@ -96,9 +96,9 @@ export class CdpHTTPResponse extends HTTPResponse {
|
|||||||
return statusText;
|
return statusText;
|
||||||
}
|
}
|
||||||
|
|
||||||
override _resolveBody(err: Error | null): void {
|
_resolveBody(err?: Error): void {
|
||||||
if (err) {
|
if (err) {
|
||||||
return this.#bodyLoadedDeferred.resolve(err);
|
return this.#bodyLoadedDeferred.reject(err);
|
||||||
}
|
}
|
||||||
return this.#bodyLoadedDeferred.resolve();
|
return this.#bodyLoadedDeferred.resolve();
|
||||||
}
|
}
|
||||||
@ -135,10 +135,7 @@ export class CdpHTTPResponse extends HTTPResponse {
|
|||||||
if (!this.#contentPromise) {
|
if (!this.#contentPromise) {
|
||||||
this.#contentPromise = this.#bodyLoadedDeferred
|
this.#contentPromise = this.#bodyLoadedDeferred
|
||||||
.valueOrThrow()
|
.valueOrThrow()
|
||||||
.then(async error => {
|
.then(async () => {
|
||||||
if (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const response = await this.#client.send(
|
const response = await this.#client.send(
|
||||||
'Network.getResponseBody',
|
'Network.getResponseBody',
|
||||||
|
@ -680,7 +680,7 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
|
|||||||
// Under certain conditions we never get the Network.responseReceived
|
// Under certain conditions we never get the Network.responseReceived
|
||||||
// event from protocol. @see https://crbug.com/883475
|
// event from protocol. @see https://crbug.com/883475
|
||||||
if (request.response()) {
|
if (request.response()) {
|
||||||
request.response()?._resolveBody(null);
|
request.response()?._resolveBody();
|
||||||
}
|
}
|
||||||
this.#forgetRequest(request, true);
|
this.#forgetRequest(request, true);
|
||||||
this.emit(NetworkManagerEvent.RequestFinished, request);
|
this.emit(NetworkManagerEvent.RequestFinished, request);
|
||||||
@ -712,7 +712,7 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
|
|||||||
request._failureText = event.errorText;
|
request._failureText = event.errorText;
|
||||||
const response = request.response();
|
const response = request.response();
|
||||||
if (response) {
|
if (response) {
|
||||||
response._resolveBody(null);
|
response._resolveBody();
|
||||||
}
|
}
|
||||||
this.#forgetRequest(request, true);
|
this.#forgetRequest(request, true);
|
||||||
this.emit(NetworkManagerEvent.RequestFailed, request);
|
this.emit(NetworkManagerEvent.RequestFailed, request);
|
||||||
|
Loading…
Reference in New Issue
Block a user