mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: webRequest.onBeforeSendHeaders not being able to modify reserved headers (#49242)
* fix: `webRequest.onBeforeSendHeaders` not being able to modify reserved headers Co-authored-by: Samuel Attard <sattard@anthropic.com> * chore: add unit test for reserved header Co-authored-by: Samuel Attard <sattard@anthropic.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <sattard@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "content/public/browser/global_request_id.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "mojo/public/cpp/system/data_pipe_producer.h"
|
||||
@@ -375,6 +376,13 @@ void SimpleURLLoaderWrapper::Start() {
|
||||
|
||||
loader_->SetAllowHttpErrorResults(true);
|
||||
loader_->SetURLLoaderFactoryOptions(request_options_);
|
||||
// Set a non-zero request ID so that the request can use the
|
||||
// TrustedHeaderClient code path for webRequest header modifications.
|
||||
// See proxying_url_loader_factory.cc for details.
|
||||
if (electron::IsBrowserProcess()) {
|
||||
loader_->SetRequestID(
|
||||
content::GlobalRequestID::MakeBrowserInitiated().request_id);
|
||||
}
|
||||
loader_->SetOnResponseStartedCallback(base::BindOnce(
|
||||
&SimpleURLLoaderWrapper::OnResponseStarted, weak_factory_.GetWeakPtr()));
|
||||
loader_->SetOnRedirectCallback(base::BindRepeating(
|
||||
|
||||
Reference in New Issue
Block a user