diff --git a/packages/playwright-core/src/server/har/harTracer.ts b/packages/playwright-core/src/server/har/harTracer.ts index 6dffaba894..41f4b14448 100644 --- a/packages/playwright-core/src/server/har/harTracer.ts +++ b/packages/playwright-core/src/server/har/harTracer.ts @@ -208,13 +208,16 @@ export class HarTracer { if (!harEntry) return; - harEntry.serverIPAddress = event.serverIPAddress; - harEntry._serverPort = event.serverPort; harEntry.response.status = event.statusCode; harEntry.response.statusText = event.statusMessage; harEntry.response.httpVersion = event.httpVersion; harEntry.response.redirectURL = event.headers.location || ''; + if (!this._options.omitServerIP) { + harEntry.serverIPAddress = event.serverIPAddress; + harEntry._serverPort = event.serverPort; + } + if (!this._options.omitTiming) { harEntry.timings = event.timings; this._computeHarEntryTotalTime(harEntry); diff --git a/tests/library/har.spec.ts b/tests/library/har.spec.ts index cd218e2ac5..17d562e2a9 100644 --- a/tests/library/har.spec.ts +++ b/tests/library/har.spec.ts @@ -847,6 +847,8 @@ it('should respect minimal mode for API Requests', async ({ contextFactory, serv expect(entries).toHaveLength(1); const [entry] = entries; expect(entry.timings).toEqual({ receive: -1, send: -1, wait: -1 }); + expect(entry.serverIPAddress).toBeUndefined(); + expect(entry._serverPort).toBeUndefined(); }); it('should include redirects from API request', async ({ contextFactory, server }, testInfo) => {