Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/playwright-core/src/server/har/harTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,15 @@ export class HarTracer {
// In WebKit security details and server ip are reported in Network.loadingFinished, so we populate
// it here to not hang in case of long chunked responses, see https://github.com/microsoft/playwright/issues/21182.
if (!this._options.omitServerIP) {
this._addBarrier(page || request.serviceWorker(), response.serverAddr(nullProgress).then(server => {
this._addBarrier(page || request.serviceWorker(), response.internalServerAddr().then(server => {
if (server?.ipAddress)
harEntry.serverIPAddress = server.ipAddress;
if (server?.port)
harEntry._serverPort = server.port;
}));
}
if (!this._options.omitSecurityDetails) {
this._addBarrier(page || request.serviceWorker(), response.securityDetails(nullProgress).then(details => {
this._addBarrier(page || request.serviceWorker(), response.internalSecurityDetails().then(details => {
if (details)
harEntry._securityDetails = details;
}));
Expand Down Expand Up @@ -374,7 +374,7 @@ export class HarTracer {
});
this._addBarrier(page || request.serviceWorker(), promise);

this._addBarrier(page || request.serviceWorker(), response.httpVersion(nullProgress).then(httpVersion => {
this._addBarrier(page || request.serviceWorker(), response.internalHttpVersion().then(httpVersion => {
harEntry.request.httpVersion = httpVersion;
harEntry.response.httpVersion = httpVersion;
}));
Expand All @@ -385,7 +385,7 @@ export class HarTracer {
this._computeHarEntryTotalTime(harEntry);

if (!this._options.omitSizes) {
this._addBarrier(page || request.serviceWorker(), response.sizes(nullProgress).then(sizes => {
this._addBarrier(page || request.serviceWorker(), response.internalSizes().then(sizes => {
harEntry.response.bodySize = sizes.responseBodySize;
harEntry.response.headersSize = sizes.responseHeadersSize;
harEntry.response._transferSize = sizes.transferSize;
Expand Down Expand Up @@ -595,13 +595,13 @@ export class HarTracer {
}

this._recordRequestOverrides(harEntry, request);
this._addBarrier(page || request.serviceWorker(), request.rawRequestHeaders(nullProgress).then(headers => {
this._addBarrier(page || request.serviceWorker(), request.internalRawRequestHeaders().then(headers => {
this._recordRequestHeadersAndCookies(harEntry, headers);
}));
// Record available headers including redirect location in case the tracing is stopped before
// response extra info is received (in Chromium).
this._recordResponseHeaders(harEntry, response.headers());
this._addBarrier(page || request.serviceWorker(), response.rawResponseHeaders(nullProgress).then(headers => {
this._addBarrier(page || request.serviceWorker(), response.internalRawResponseHeaders().then(headers => {
this._recordResponseHeaders(harEntry, headers);
}));
}
Expand Down
26 changes: 17 additions & 9 deletions packages/playwright-core/src/server/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class Request extends SdkObject {
}

async rawRequestHeaders(progress: Progress): Promise<HeadersArray> {
return await this.raceWithPageClosure(progress, this._rawRequestHeaders());
return await this.raceWithPageClosure(progress, this.internalRawRequestHeaders());
}

async response(progress: Progress): Promise<Response | null> {
Expand Down Expand Up @@ -280,7 +280,7 @@ export class Request extends SdkObject {
this._rawRequestHeadersPromise.resolve(headers || this._headers);
}

private async _rawRequestHeaders(): Promise<HeadersArray> {
async internalRawRequestHeaders(): Promise<HeadersArray> {
return this._overrides?.headers || this._rawRequestHeadersPromise;
}

Expand Down Expand Up @@ -336,7 +336,7 @@ export class Request extends SdkObject {
}

async _requestHeadersSize(): Promise<number> {
return requestHeadersSize(await this._rawRequestHeaders(), this.url(), this.method());
return requestHeadersSize(await this.internalRawRequestHeaders(), this.url(), this.method());
}
}

Expand Down Expand Up @@ -553,19 +553,19 @@ export class Response extends SdkObject {
}

async serverAddr(progress: Progress): Promise<RemoteAddr | null> {
return (await this._request.raceWithPageClosure(progress, this._serverAddrPromise)) || null;
return await this._request.raceWithPageClosure(progress, this.internalServerAddr());
}

async rawResponseHeaders(progress: Progress): Promise<NameValue[]> {
return await this._request.raceWithPageClosure(progress, this._rawResponseHeadersPromise);
return await this._request.raceWithPageClosure(progress, this.internalRawResponseHeaders());
}

async httpVersion(progress: Progress): Promise<string> {
return await this._request.raceWithPageClosure(progress, this._httpVersion());
return await this._request.raceWithPageClosure(progress, this.internalHttpVersion());
}

async sizes(progress: Progress): Promise<ResourceSizes> {
return await this._request.raceWithPageClosure(progress, this._sizes());
return await this._request.raceWithPageClosure(progress, this.internalSizes());
}

_serverAddrFinished(addr?: RemoteAddr) {
Expand Down Expand Up @@ -634,6 +634,14 @@ export class Response extends SdkObject {
return await this._securityDetailsPromise || null;
}

async internalServerAddr(): Promise<RemoteAddr | null> {
return await this._serverAddrPromise || null;
}

async internalRawResponseHeaders(): Promise<HeadersArray> {
return await this._rawResponseHeadersPromise;
}

internalBody(): Promise<Buffer> {
if (!this._contentPromise) {
this._contentPromise = this._finishedPromise.then(async () => {
Expand Down Expand Up @@ -661,7 +669,7 @@ export class Response extends SdkObject {
return this._request.frame();
}

private async _httpVersion(): Promise<string> {
async internalHttpVersion(): Promise<string> {
const httpVersion = await this._httpVersionPromise || null;
if (!httpVersion)
return 'HTTP/1.1';
Expand All @@ -685,7 +693,7 @@ export class Response extends SdkObject {
return responseHeadersSize(await this._rawResponseHeadersPromise, this.statusText());
}

private async _sizes(): Promise<ResourceSizes> {
async internalSizes(): Promise<ResourceSizes> {
const requestHeadersSize = await this._request._requestHeadersSize();
const responseHeadersSize = await this.responseHeadersSize();

Expand Down
Loading