-
Notifications
You must be signed in to change notification settings - Fork 4.7k
chore(bidi): fix header overrides for intercepted redirects #37754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hbenl
wants to merge
1
commit into
microsoft:main
Choose a base branch
from
hbenl:header-overrides-intercepted-redirects
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+19
−6
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this different from juggler and simply not providing an override is not sufficient? Is it because we always preserve the original in this code ?
What is the semantics of overridden headers passed to
network.continueRequest
in Firefox - will overrides always replace all original headers or they are merged and if a header is present on the original request but not in the overrides, it will be preserved on the request? I believe for most of the network service headers if there is no explicit override, the default value will be sent (at least in Chromium and WebKit). If in Firefox Bidi the headers must contain all final headers then I believe we should change the logic and merge original headers with the overrides. In this particular case it would mean that we always add thehost
header regardless of wether it is in _alreadyContinuedHeaders or not (it should probably not be there as we don't allow to override it).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To provide a bit more context, the header overrides is a mess for the headers that are added by the network service. I believe what we settled on is that we don't want to support overrides of any of the forbidden headers and want them to be propagated as is. I don't think we currently enforce that in all browsers though, so the behavior may vary. For the host and cookie headers there were explicit reports, so we have special handling of those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Firefox BiDi the overrides always replace all original headers (and network requests stall if the overrides don't contain a Host header) whereas Chrome BiDi currently doesn't expect the overrides to contain a Host header (the network request stalls if they do). But the consensus on the BiDi spec seems to be that Firefox' behavior is the correct one ("We should consider data from the BiDi client safe, and provide whatever they want to.").
To get the desired Playwright behavior that you described with BiDi, I think we should
Do you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly agree with the exception that I don't think anyone would appreciate stalling when an unexpected override is passed or expected header is not passed, immediately throwing a validation error in that case sounds more user friendly.
I would throw in this case. There is also an option of not throwing an applying overrides in best effort manner, basically not reporting an error when the override is lost.
Yes, agree with this.
As far as I know in Chromium at the interception time we don't have headers added by the network stack. There is a special dance for fetching "would be sent" cookies, but there are other headers too added by the network service. Due to this limitation the user cannot easily pass complete set of the headers where they override say just one.