mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(tracing): record available response headers without waiting for extra info (#23483)
Fixes #23115
This commit is contained in:
parent
dd3ca6907a
commit
401fc4cb9e
@ -478,16 +478,24 @@ export class HarTracer {
|
|||||||
this._addBarrier(page || request.serviceWorker(), request.rawRequestHeaders().then(headers => {
|
this._addBarrier(page || request.serviceWorker(), request.rawRequestHeaders().then(headers => {
|
||||||
this._recordRequestHeadersAndCookies(harEntry, headers);
|
this._recordRequestHeadersAndCookies(harEntry, headers);
|
||||||
}));
|
}));
|
||||||
|
// Record available headers including redirect location in case the tracing is stopped before
|
||||||
|
// reponse extra info is received (in Chromium).
|
||||||
|
this._recordResponseHeaders(harEntry, response.headers());
|
||||||
this._addBarrier(page || request.serviceWorker(), response.rawResponseHeaders().then(headers => {
|
this._addBarrier(page || request.serviceWorker(), response.rawResponseHeaders().then(headers => {
|
||||||
|
this._recordResponseHeaders(harEntry, headers);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private _recordResponseHeaders(harEntry: har.Entry, headers: HeadersArray) {
|
||||||
if (!this._options.omitCookies) {
|
if (!this._options.omitCookies) {
|
||||||
for (const header of headers.filter(header => header.name.toLowerCase() === 'set-cookie'))
|
harEntry.response.cookies = headers
|
||||||
harEntry.response.cookies.push(parseCookie(header.value));
|
.filter(header => header.name.toLowerCase() === 'set-cookie')
|
||||||
|
.map(header => parseCookie(header.value));
|
||||||
}
|
}
|
||||||
harEntry.response.headers = headers;
|
harEntry.response.headers = headers;
|
||||||
const contentType = headers.find(header => header.name.toLowerCase() === 'content-type');
|
const contentType = headers.find(header => header.name.toLowerCase() === 'content-type');
|
||||||
if (contentType)
|
if (contentType)
|
||||||
harEntry.response.content.mimeType = contentType.value;
|
harEntry.response.content.mimeType = contentType.value;
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _computeHarEntryTotalTime(harEntry: har.Entry) {
|
private _computeHarEntryTotalTime(harEntry: har.Entry) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user