mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-12 11:50:22 +03:00
docs: sizes enhancements (#8771)
This commit is contained in:
parent
ffb5ddbcde
commit
25b5927a4d
@ -201,8 +201,7 @@ Returns the matching [Response] object, or `null` if the response was not receiv
|
|||||||
- `responseBodySize` <[int]> Size of the received response body (encoded) in bytes.
|
- `responseBodySize` <[int]> Size of the received response body (encoded) in bytes.
|
||||||
- `responseHeadersSize` <[int]> Total number of bytes from the start of the HTTP response message until (and including) the double CRLF before the body.
|
- `responseHeadersSize` <[int]> Total number of bytes from the start of the HTTP response message until (and including) the double CRLF before the body.
|
||||||
|
|
||||||
Returns resource size information for given request. Requires the response to be finished via [`method: Response.finished`]
|
Returns resource size information for given request.
|
||||||
to ensure the info is available.
|
|
||||||
|
|
||||||
## method: Request.timing
|
## method: Request.timing
|
||||||
- returns: <[Object]>
|
- returns: <[Object]>
|
||||||
|
@ -145,7 +145,7 @@ export class Request extends ChannelOwner<channels.RequestChannel, channels.Requ
|
|||||||
if (!response)
|
if (!response)
|
||||||
return this._headers;
|
return this._headers;
|
||||||
return response._wrapApiCall(async (channel: channels.ResponseChannel) => {
|
return response._wrapApiCall(async (channel: channels.ResponseChannel) => {
|
||||||
return await (await channel.rawRequestHeaders()).headers;
|
return (await channel.rawRequestHeaders()).headers;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ it('should set bodySize and headersSize', async ({ page, server }) => {
|
|||||||
page.waitForEvent('request'),
|
page.waitForEvent('request'),
|
||||||
page.evaluate(() => fetch('./get', { method: 'POST', body: '12345' }).then(r => r.text())),
|
page.evaluate(() => fetch('./get', { method: 'POST', body: '12345' }).then(r => r.text())),
|
||||||
]);
|
]);
|
||||||
await (await request.response()).finished();
|
|
||||||
const sizes = await request.sizes();
|
const sizes = await request.sizes();
|
||||||
expect(sizes.requestBodySize).toBe(5);
|
expect(sizes.requestBodySize).toBe(5);
|
||||||
expect(sizes.requestHeadersSize).toBeGreaterThanOrEqual(250);
|
expect(sizes.requestHeadersSize).toBeGreaterThanOrEqual(250);
|
||||||
|
3
types/types.d.ts
vendored
3
types/types.d.ts
vendored
@ -13141,8 +13141,7 @@ export interface Request {
|
|||||||
response(): Promise<null|Response>;
|
response(): Promise<null|Response>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns resource size information for given request. Requires the response to be finished via
|
* Returns resource size information for given request.
|
||||||
* [response.finished()](https://playwright.dev/docs/api/class-response#response-finished) to ensure the info is available.
|
|
||||||
*/
|
*/
|
||||||
sizes(): Promise<{
|
sizes(): Promise<{
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user