Skip to content

Conversation

@yepitschunked
Copy link

This was previously closed in #38255 due to inactivity. This PR has been updated with the feedback from @yury-s on the previous PR to avoid a bug with single set-cookie headers.

Following PR description is copied from the original:

Route.fulfill currently does not support multiple headers with the same name (#37342). There are workarounds when using this API directly (merging headers, tweaking the header name casing, etc.), but this is problematic for routeFromHAR, which depends on
this API internally. This patch adds special handling for set-cookie headers within harRouter to merge them into one header. There's some precedent for treating set-cookie specially at various places in the codebase (ex:

const sep = name.toLowerCase() === 'set-cookie' ? setCookieSeparator : separator;
,
function splitSetCookieHeader(headers: types.HeadersArray): types.HeadersArray {
), so I think this is okay.

Route.fulfill currently does not support multiple headers with the same
name (microsoft#37342). There are workarounds when using this API directly
(merging headers, tweaking the header name casing, etc.), but this is
problematic for routeFromHAR, which depends on
this API internally. This patch adds special handling for set-cookie
headers within harRouter to merge them into one header. There's some
precedent for treating set-cookie specially at various places in the
codebase (ex:
https://github.com/microsoft/playwright/blob/f54478a23e0daa450fe524905eabc8aabf6efb07/packages/playwright-core/src/utils/isomorphic/headers.ts#L29,
https://github.com/microsoft/playwright/blob/baeb065e9ea84502f347129a0b896a85d2a8dada/packages/playwright-core/src/server/chromium/crNetworkManager.ts#L675), so I think this is okay.
expect(await page2.evaluate(fetchFunction, { path: '/echo', body: '12' })).toBe('12');
});

it('should replay requests with multiple set-cookie headers properly', async ({ context, asset }) => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this test is still necessary with the multi-cookie test below (seems like that one both records and replays a HAR)

expect(cookie2.split('; ').sort().join('; ')).toBe('first=foo');
});

it('should record multiple set-cookie headers', {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Skn0tt Skn0tt requested a review from yury-s December 9, 2025 07:20
@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

Test results for "MCP"

2688 passed, 116 skipped


Merge workflow run.

@github-actions
Copy link
Contributor

Test results for "tests 1"

7 flaky ⚠️ [chromium-library] › library/inspector/recorder-api.spec.ts:120 › should type `@chromium-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1079 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-page] › page/page-wait-for-function.spec.ts:104 › should work with strict CSP policy `@firefox-ubuntu-22.04-node18`
⚠️ [playwright-test] › ui-mode-test-attachments.spec.ts:21 › should contain text attachment `@macos-latest-node18-2`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:183 › should show snapshots for steps `@macos-latest-node18-2`
⚠️ [playwright-test] › ui-mode-test-attachments.spec.ts:21 › should contain text attachment `@ubuntu-latest-node18-2`
⚠️ [playwright-test] › ui-mode-test-attachments.spec.ts:102 › should linkify string attachments `@ubuntu-latest-node18-2`

39445 passed, 792 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant