Closed Bug 1940389 Opened 1 year ago Closed 1 month ago

Set-Cookie response headers are merged in BiDi network events

Categories

(Remote Protocol :: WebDriver BiDi, defect, P2)

defect
Points:
2

Tracking

(firefox160 fixed)

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Depends on 1 open bug)

Details

(Whiteboard: [webdriver:m22], [wptsync upstream][webdriver:relnote])

Attachments

(2 external files)

STRs:

  • setup a server which returns several set-cookie headers
  • listen for network response events with WebDriver BiDi (eg network.responseCompleted)
  • send request

ER:
The network event should contain several individual headers with the name "set-cookie"

AR:
The network event contains only one set-cookie header, with values concatenated with \n

Fails a playwright test:
page/page-network-response.spec.ts :: should report multiple set-cookie headers

In general, using visitOriginalResponseHeaders at https://searchfox.org/mozilla-central/rev/7d1b5c88343879056168aa710a9ee743392604c0/remote/shared/NetworkResponse.sys.mjs#249-253

this.#channel.visitResponseHeaders({
  visitHeader(name, value) {
    headers.push([name, value]);
  },
});

would help with this issue. However, if we use this API, we no longer get the modified response headers if clients used network.continueRequest.

Valentin, do you know if there is a way to get the "current" response headers, but avoid having headers such as Set-Cookie "flattened" as a single cookie? I feel like we would need another entry point here?

Points: --- → 2
Flags: needinfo?(valentin.gosu)
Priority: -- → P2
Whiteboard: [webdriver:backlog]
Severity: -- → S3

Hi Julian,

This is a known issue with nsHttpHeaderArray - any headers that are not eVarietyResponseNetOriginal are saved in a merged form.
We recently addressed this issue in bug 1935948, though the fix was to split the cookie header by \n.
We've been talking about refactoring nsHttpHeaderArray for a while to address this limitation, but it might be a few months until we manage to land that. In the mean time, it should be OK to split the value by \n.

Flags: needinfo?(valentin.gosu)
Depends on: 1943266

While looking at current playwright failures, I think 3 playwright tests are currently failing because of this:

  • page/page-network-response.spec.ts : should report multiple set-cookie headers
  • library/har.spec.ts : should include set-cookies
  • library/har.spec.ts : should include set-cookies with comma

Hi Maksim, I wrote new tests to check that we properly expose each value for Set-Cookie response headers, and I noticed that Chrome is currently failing them. So I guess you must have the same implementation issue as we have on Firefox. I don't plan to land the new tests immediately, so that's just a heads up in case you have any feedback about this.

Flags: needinfo?(sadym)

The WPT patch in D328644 LGTM. We'll align Chromium with the spec once the WPT lands.

Flags: needinfo?(sadym)

Thanks for checking Maksim!

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Whiteboard: [webdriver:backlog] → [webdriver:m22]
Attachment #9647632 - Attachment description: WIP: Bug 1940389 - [bidi] Split Set-Cookie header value on \n → Bug 1940389 - [bidi] Split Set-Cookie header value on \n
Attachment #9647633 - Attachment description: WIP: Bug 1940389 - [wdspec] Add bidi tests for set-cookie header with multiple values → Bug 1940389 - [wdspec] Add bidi tests for set-cookie header with multiple values
Attachment #9647632 - Attachment description: Bug 1940389 - [bidi] Split Set-Cookie header value on \n → Bug 1940389 - [bidi] Split newline-merged headers value on \n (e.g. set-cookie)
Attachment #9647633 - Attachment description: Bug 1940389 - [wdspec] Add bidi tests for set-cookie header with multiple values → Bug 1940389 - [wdspec] Add bidi tests for newline-merged headers with multiple values
Pushed by jdescottes@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a13f08cdee23 https://hg.mozilla.org/integration/autoland/rev/d620ae064a58 [bidi] Split newline-merged headers value on \n (e.g. set-cookie) r=webdriver-reviewers,Sasha https://github.com/mozilla-firefox/firefox/commit/60497ff5ba71 https://hg.mozilla.org/integration/autoland/rev/369590a24497 [wdspec] Add bidi tests for newline-merged headers with multiple values r=webdriver-reviewers,Sasha

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/63574 for changes under testing/web-platform/tests

Whiteboard: [webdriver:m22] → [webdriver:m22], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch

Upstream PR merged by moz-wptsync-bot

Whiteboard: [webdriver:m22], [wptsync upstream] → [webdriver:m22], [wptsync upstream][webdriver:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: