Open thomhurst opened 3 months ago
We can collect upvotes for it and see if there is demand.
Is this request only about SetExtraHTTPHeadersAsync
?
For Request and Response, we provide a way to get them:
Yes this would be a breaking change, but we can collect upvotes for it and consider it for the next major version / provide a different method for it if there is demand.
Is this request only about
SetExtraHTTPHeadersAsync
?For Request and Response, we provide a way to get them:
I don't think SetExtraHTTPHeadersAsync
is actually the problem. I think it's that IRequest.Headers
is a Dictionary<string, string>
- So if you try and store a new value with the same key it'll just overwrite the old one. But I may be wrong there.
It also affects other methods like IRequest.HeaderValueAsync(string key)
- Which only return one value.
IResponse.Headers
is also a Dictionary<string, string>
so probably has the same problem (but I haven't tested that.)
Interestingly those docs say "Headers with multiple entries, such as Set-Cookie, appear in the array multiple times.". Is that because Set-Cookie uses a semi-colon delimiter?
Because the HTTP spec AFAIK also supports multiple same name headers too. So two ways to do the same thing, and so both should be supported IMO.
I did try using HeadersArrayAsync
but still only Bar3
was returned.
Yes, SetExtraHTTPHeadersAsync does not support that. So I'll mark it as a feature request for now.
Request/Response with HeadersArrayAsync
support generally speaking multi-header scenarios. So we expose an API for it there. It returns still one, because SetExtraHTTPHeadersAsync only supports a single header.
Version
1.45.1
Steps to reproduce
Expected behavior
I expected to see the headers containing:
Actual behavior
I see just one header sent:
Additional context
Multiple headers with the same name are valid in the HTTP spec, and so Playwright should match that behaviour. The simplest solution would be for the headers dictionary to hold a collection as the value rather than a single string, though this would be a breaking change.
Environment