feat(HTTPResponse): expose timing information (#8025)
This commit is contained in:
parent
5346e70ffc
commit
30b3d49b0d
25
docs/api.md
25
docs/api.md
@ -375,6 +375,7 @@
|
|||||||
* [httpResponse.status()](#httpresponsestatus)
|
* [httpResponse.status()](#httpresponsestatus)
|
||||||
* [httpResponse.statusText()](#httpresponsestatustext)
|
* [httpResponse.statusText()](#httpresponsestatustext)
|
||||||
* [httpResponse.text()](#httpresponsetext)
|
* [httpResponse.text()](#httpresponsetext)
|
||||||
|
* [httpResponse.timing()](#httpresponsetiming)
|
||||||
* [httpResponse.url()](#httpresponseurl)
|
* [httpResponse.url()](#httpresponseurl)
|
||||||
- [class: SecurityDetails](#class-securitydetails)
|
- [class: SecurityDetails](#class-securitydetails)
|
||||||
* [securityDetails.issuer()](#securitydetailsissuer)
|
* [securityDetails.issuer()](#securitydetailsissuer)
|
||||||
@ -5231,6 +5232,30 @@ Contains the status text of the response (e.g. usually an "OK" for a success).
|
|||||||
|
|
||||||
- returns: <[Promise]<[string]>> Promise which resolves to a text representation of response body.
|
- returns: <[Promise]<[string]>> Promise which resolves to a text representation of response body.
|
||||||
|
|
||||||
|
#### httpResponse.timing()
|
||||||
|
|
||||||
|
- returns: <?[Object]>
|
||||||
|
- `requestTime` <[number]> baseline in seconds
|
||||||
|
- `proxyStart` <[number]> started resolving proxy (milliseconds since requestTime)
|
||||||
|
- `proxyEnd` <[number]> finished resolving proxy (milliseconds since requestTime)
|
||||||
|
- `dnsStart` <[number]> started DNS address resolve (milliseconds since requestTime)
|
||||||
|
- `dnsEnd` <[number]> finished DNS address resolve (milliseconds since requestTime)
|
||||||
|
- `connectStart` <[number]> started connecting to the remote host (milliseconds since requestTime)
|
||||||
|
- `connectEnd` <[number]> connected to the remote host (milliseconds since requestTime)
|
||||||
|
- `sslStart` <[number]> started SSL handshake (milliseconds since requestTime)
|
||||||
|
- `sslEnd` <[number]> finished SSL handshake (milliseconds since requestTime)
|
||||||
|
- `workerStart` <[number]> started running ServiceWorker (milliseconds since requestTime)
|
||||||
|
- `workerReady` <[number]> finished Starting ServiceWorker (milliseconds since requestTime)
|
||||||
|
- `workerFetchStart` <[number]> started fetch event (milliseconds since requestTime)
|
||||||
|
- `workerRespondWithSettled` <[number]> settled fetch event respondWith promise (milliseconds since requestTime)
|
||||||
|
- `sendStart` <[number]> started sending request (milliseconds since requestTime)
|
||||||
|
- `sendEnd` <[number]> finished sending request (milliseconds since requestTime)
|
||||||
|
- `pushStart` <[number]> time the server started pushing request (milliseconds since requestTime)
|
||||||
|
- `pushEnd` <[number]> time the server finished pushing request (milliseconds since requestTime)
|
||||||
|
- `receiveHeadersEnd` <[number]> finished receiving response headers (milliseconds since requestTime)
|
||||||
|
|
||||||
|
Timing information related to the response.
|
||||||
|
|
||||||
#### httpResponse.url()
|
#### httpResponse.url()
|
||||||
|
|
||||||
- returns: <[string]>
|
- returns: <[string]>
|
||||||
|
@ -57,6 +57,7 @@ export class HTTPResponse {
|
|||||||
private _fromServiceWorker: boolean;
|
private _fromServiceWorker: boolean;
|
||||||
private _headers: Record<string, string> = {};
|
private _headers: Record<string, string> = {};
|
||||||
private _securityDetails: SecurityDetails | null;
|
private _securityDetails: SecurityDetails | null;
|
||||||
|
private _timing: Protocol.Network.ResourceTiming | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -93,6 +94,7 @@ export class HTTPResponse {
|
|||||||
this._securityDetails = responsePayload.securityDetails
|
this._securityDetails = responsePayload.securityDetails
|
||||||
? new SecurityDetails(responsePayload.securityDetails)
|
? new SecurityDetails(responsePayload.securityDetails)
|
||||||
: null;
|
: null;
|
||||||
|
this._timing = responsePayload.timing;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,6 +174,13 @@ export class HTTPResponse {
|
|||||||
return this._securityDetails;
|
return this._securityDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns Timing information related to the response.
|
||||||
|
*/
|
||||||
|
timing(): Protocol.Network.ResourceTiming | null {
|
||||||
|
return this._timing;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns Promise which resolves to a buffer with response body.
|
* @returns Promise which resolves to a buffer with response body.
|
||||||
*/
|
*/
|
||||||
|
@ -430,6 +430,17 @@ describe('network', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describeFailsFirefox('Response.timing', function () {
|
||||||
|
it('returns timing information', async () => {
|
||||||
|
const { page, server } = getTestState();
|
||||||
|
const responses = [];
|
||||||
|
page.on('response', (response) => responses.push(response));
|
||||||
|
await page.goto(server.EMPTY_PAGE);
|
||||||
|
expect(responses.length).toBe(1);
|
||||||
|
expect(responses[0].timing().receiveHeadersEnd).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describeFailsFirefox('Network Events', function () {
|
describeFailsFirefox('Network Events', function () {
|
||||||
it('Page.Events.Request', async () => {
|
it('Page.Events.Request', async () => {
|
||||||
const { page, server } = getTestState();
|
const { page, server } = getTestState();
|
||||||
|
Loading…
Reference in New Issue
Block a user