docs(fetch): ApiResponse -> APIResponse (#9623)

This commit is contained in:
Yury Semikhatsky 2021-10-19 11:17:23 -07:00 committed by GitHub
parent ade2171c4b
commit 7e52357178
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 38 deletions

View file

@ -7,7 +7,7 @@ the cookies from the corresponding [BrowserContext]. This means that if you log
will be logged in and vice versa. will be logged in and vice versa.
## async method: APIRequestContext.delete ## async method: APIRequestContext.delete
- returns: <[ApiResponse]> - returns: <[APIResponse]>
Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its response. Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its response.
The method will populate request cookies from the context and update The method will populate request cookies from the context and update
@ -22,11 +22,11 @@ context cookies from the response. The method will automatically follow redirect
## async method: APIRequestContext.dispose ## async method: APIRequestContext.dispose
All responses returned by [`method: APIRequestContext.get`] and similar methods are stored in the memory, so that you can later call [`method: ApiResponse.body`]. This method All responses returned by [`method: APIRequestContext.get`] and similar methods are stored in the memory, so that you can later call [`method: APIResponse.body`]. This method
discards all stored responses, and makes [`method: ApiResponse.body`] throw "Response disposed" error. discards all stored responses, and makes [`method: APIResponse.body`] throw "Response disposed" error.
## async method: APIRequestContext.fetch ## async method: APIRequestContext.fetch
- returns: <[ApiResponse]> - returns: <[APIResponse]>
Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
context cookies from the response. The method will automatically follow redirects. context cookies from the response. The method will automatically follow redirects.
@ -53,7 +53,7 @@ If set changes the fetch method (e.g. [PUT](https://developer.mozilla.org/en-US/
### option: APIRequestContext.fetch.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%% ### option: APIRequestContext.fetch.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
## async method: APIRequestContext.get ## async method: APIRequestContext.get
- returns: <[ApiResponse]> - returns: <[APIResponse]>
Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response. Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response.
The method will populate request cookies from the context and update The method will populate request cookies from the context and update
@ -67,7 +67,7 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.get.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%% ### option: APIRequestContext.get.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
## async method: APIRequestContext.head ## async method: APIRequestContext.head
- returns: <[ApiResponse]> - returns: <[APIResponse]>
Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response. Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response.
The method will populate request cookies from the context and update The method will populate request cookies from the context and update
@ -81,7 +81,7 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.head.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%% ### option: APIRequestContext.head.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
## async method: APIRequestContext.patch ## async method: APIRequestContext.patch
- returns: <[ApiResponse]> - returns: <[APIResponse]>
Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response. Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response.
The method will populate request cookies from the context and update The method will populate request cookies from the context and update
@ -98,7 +98,7 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.patch.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%% ### option: APIRequestContext.patch.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
## async method: APIRequestContext.post ## async method: APIRequestContext.post
- returns: <[ApiResponse]> - returns: <[APIResponse]>
Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response. Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response.
The method will populate request cookies from the context and update The method will populate request cookies from the context and update
@ -115,7 +115,7 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.post.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%% ### option: APIRequestContext.post.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
## async method: APIRequestContext.put ## async method: APIRequestContext.put
- returns: <[ApiResponse]> - returns: <[APIResponse]>
Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response. Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response.
The method will populate request cookies from the context and update The method will populate request cookies from the context and update

View file

@ -1,23 +1,23 @@
# class: ApiResponse # class: APIResponse
* langs: js * langs: js
[ApiResponse] class represents responses returned by [`method: APIRequestContext.get`] and similar methods. [APIResponse] class represents responses returned by [`method: APIRequestContext.get`] and similar methods.
## async method: ApiResponse.body ## async method: APIResponse.body
- returns: <[Buffer]> - returns: <[Buffer]>
Returns the buffer with response body. Returns the buffer with response body.
## async method: ApiResponse.dispose ## async method: APIResponse.dispose
Disposes the body of this response. If not called then the body will stay in memory until the context closes. Disposes the body of this response. If not called then the body will stay in memory until the context closes.
## method: ApiResponse.headers ## method: APIResponse.headers
- returns: <[Object]<[string], [string]>> - returns: <[Object]<[string], [string]>>
An object with all the response HTTP headers associated with this response. An object with all the response HTTP headers associated with this response.
## method: ApiResponse.headersArray ## method: APIResponse.headersArray
- returns: <[Array]<[Object]>> - returns: <[Array]<[Object]>>
- `name` <[string]> Name of the header. - `name` <[string]> Name of the header.
- `value` <[string]> Value of the header. - `value` <[string]> Value of the header.
@ -25,7 +25,7 @@ An object with all the response HTTP headers associated with this response.
An array with all the request HTTP headers associated with this response. Header names are not lower-cased. An array with all the request HTTP headers associated with this response. Header names are not lower-cased.
Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
## async method: ApiResponse.json ## async method: APIResponse.json
* langs: js, python * langs: js, python
- returns: <[Serializable]> - returns: <[Serializable]>
@ -33,7 +33,7 @@ Returns the JSON representation of response body.
This method will throw if the response body is not parsable via `JSON.parse`. This method will throw if the response body is not parsable via `JSON.parse`.
## async method: ApiResponse.json ## async method: APIResponse.json
* langs: csharp * langs: csharp
- returns: <[null]|[JsonElement]> - returns: <[null]|[JsonElement]>
@ -41,27 +41,27 @@ Returns the JSON representation of response body.
This method will throw if the response body is not parsable via `JSON.parse`. This method will throw if the response body is not parsable via `JSON.parse`.
## method: ApiResponse.ok ## method: APIResponse.ok
- returns: <[boolean]> - returns: <[boolean]>
Contains a boolean stating whether the response was successful (status in the range 200-299) or not. Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
## method: ApiResponse.status ## method: APIResponse.status
- returns: <[int]> - returns: <[int]>
Contains the status code of the response (e.g., 200 for a success). Contains the status code of the response (e.g., 200 for a success).
## method: ApiResponse.statusText ## method: APIResponse.statusText
- returns: <[string]> - returns: <[string]>
Contains the status text of the response (e.g. usually an "OK" for a success). Contains the status text of the response (e.g. usually an "OK" for a success).
## async method: ApiResponse.text ## async method: APIResponse.text
- returns: <[string]> - returns: <[string]>
Returns the text representation of response body. Returns the text representation of response body.
## method: ApiResponse.url ## method: APIResponse.url
- returns: <[string]> - returns: <[string]>
Contains the URL of the response. Contains the URL of the response.

View file

@ -222,9 +222,9 @@ is resolved relative to the current working directory.
### option: Route.fulfill.response ### option: Route.fulfill.response
* langs: js * langs: js
- `response` <[ApiResponse]> - `response` <[APIResponse]>
[ApiResponse] to fulfill route's request with. Individual fields of the response (such as headers) can be overridden using fulfill options. [APIResponse] to fulfill route's request with. Individual fields of the response (such as headers) can be overridden using fulfill options.
## method: Route.request ## method: Route.request
- returns: <[Request]> - returns: <[Request]>

View file

@ -34,7 +34,7 @@ export { Frame } from './frame';
export { Keyboard, Mouse, Touchscreen } from './input'; export { Keyboard, Mouse, Touchscreen } from './input';
export { JSHandle } from './jsHandle'; export { JSHandle } from './jsHandle';
export { Request, Response, Route, WebSocket } from './network'; export { Request, Response, Route, WebSocket } from './network';
export { Fetch as APIRequest, FetchRequest as APIRequestContext, FetchResponse as ApiResponse } from './fetch'; export { Fetch as APIRequest, FetchRequest as APIRequestContext, FetchResponse as APIResponse } from './fetch';
export { Page } from './page'; export { Page } from './page';
export { Selectors } from './selectors'; export { Selectors } from './selectors';
export { Tracing } from './tracing'; export { Tracing } from './tracing';

View file

@ -202,7 +202,7 @@ export class FetchRequest extends ChannelOwner<channels.FetchRequestChannel, cha
} }
} }
export class FetchResponse implements api.ApiResponse { export class FetchResponse implements api.APIResponse {
private readonly _initializer: channels.FetchResponse; private readonly _initializer: channels.FetchResponse;
private readonly _headers: RawHeaders; private readonly _headers: RawHeaders;
private readonly _request: FetchRequest; private readonly _request: FetchRequest;

View file

@ -326,7 +326,7 @@ export class Route extends ChannelOwner<channels.RouteChannel, channels.RouteIni
}); });
} }
async fulfill(options: { response?: api.Response | api.ApiResponse, status?: number, headers?: Headers, contentType?: string, body?: string | Buffer, path?: string } = {}) { async fulfill(options: { response?: api.Response | api.APIResponse, status?: number, headers?: Headers, contentType?: string, body?: string | Buffer, path?: string } = {}) {
return this._wrapApiCall(async (channel: channels.RouteChannel) => { return this._wrapApiCall(async (channel: channels.RouteChannel) => {
let useInterceptedResponseBody; let useInterceptedResponseBody;
let fetchResponseUid; let fetchResponseUid;

View file

@ -11754,7 +11754,7 @@ export interface APIRequestContext {
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. * Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/ */
timeout?: number; timeout?: number;
}): Promise<ApiResponse>; }): Promise<APIResponse>;
/** /**
* All responses returned by * All responses returned by
@ -11840,7 +11840,7 @@ export interface APIRequestContext {
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. * Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/ */
timeout?: number; timeout?: number;
}): Promise<ApiResponse>; }): Promise<APIResponse>;
/** /**
* Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response. The * Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response. The
@ -11874,7 +11874,7 @@ export interface APIRequestContext {
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. * Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/ */
timeout?: number; timeout?: number;
}): Promise<ApiResponse>; }): Promise<APIResponse>;
/** /**
* Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response. * Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response.
@ -11908,7 +11908,7 @@ export interface APIRequestContext {
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. * Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/ */
timeout?: number; timeout?: number;
}): Promise<ApiResponse>; }): Promise<APIResponse>;
/** /**
* Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response. * Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response.
@ -11979,7 +11979,7 @@ export interface APIRequestContext {
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. * Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/ */
timeout?: number; timeout?: number;
}): Promise<ApiResponse>; }): Promise<APIResponse>;
/** /**
* Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response. * Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response.
@ -12050,7 +12050,7 @@ export interface APIRequestContext {
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. * Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/ */
timeout?: number; timeout?: number;
}): Promise<ApiResponse>; }): Promise<APIResponse>;
/** /**
* Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response. The * Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response. The
@ -12121,7 +12121,7 @@ export interface APIRequestContext {
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. * Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/ */
timeout?: number; timeout?: number;
}): Promise<ApiResponse>; }): Promise<APIResponse>;
/** /**
* Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to * Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to
@ -12169,11 +12169,11 @@ export interface APIRequestContext {
} }
/** /**
* [ApiResponse] class represents responses returned by * [APIResponse] class represents responses returned by
* [apiRequestContext.get(url[, options])](https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get) * [apiRequestContext.get(url[, options])](https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get)
* and similar methods. * and similar methods.
*/ */
export interface ApiResponse { export interface APIResponse {
/** /**
* Returns the buffer with response body. * Returns the buffer with response body.
*/ */
@ -14234,10 +14234,10 @@ export interface Route {
path?: string; path?: string;
/** /**
* [ApiResponse] to fulfill route's request with. Individual fields of the response (such as headers) can be overridden * [APIResponse] to fulfill route's request with. Individual fields of the response (such as headers) can be overridden
* using fulfill options. * using fulfill options.
*/ */
response?: ApiResponse; response?: APIResponse;
/** /**
* Response status code, defaults to `200`. * Response status code, defaults to `200`.