Files
electron/patches/chromium/feat_expose_raw_response_headers_from_urlloader.patch
electron-roller[bot] 4bcbc955dd chore: bump chromium to 130.0.6695.0 (main) (#43454)
* chore: bump chromium in DEPS to 130.0.6673.0

* chore: bump chromium in DEPS to 130.0.6675.0

* chore: bump chromium in DEPS to 130.0.6677.2

* chore: bump chromium in DEPS to 130.0.6679.0

* 5802981: [Partitioned Popins] UKM

https://chromium-review.googlesource.com/c/chromium/src/+/5802981

* 5799275: ash: Create //chrome/browser/ui/ash/web_view

https://chromium-review.googlesource.com/c/chromium/src/+/5799275

* 5791853: [PWA] Allow WebContentsImpl::CreateNewWindow() to use new web contents for loading url

https://chromium-review.googlesource.com/c/chromium/src/+/5791853

* 5805208: Move third_party/jacoco to a cipd/ subdirectory.

https://chromium-review.googlesource.com/c/chromium/src/+/5805208

* chore: fixup patch indices

* 5771091: Introduce InputManager class for handling input in Viz.

https://chromium-review.googlesource.com/c/chromium/src/+/5771091

* 5498921: [Permission] Remove SubscribeToPermissionStatusChange from PermissionManager

https://chromium-review.googlesource.com/c/chromium/src/+/5498921

* 5791853: [PWA] Allow WebContentsImpl::CreateNewWindow() to use new web contents for loading url

https://chromium-review.googlesource.com/c/chromium/src/+/5791853

* 5801311: Don't use int for bindings

https://chromium-review.googlesource.com/c/chromium/src/+/5801311

* 5548827: [Web Install] Define the web-app-installation PermissionPolicy

https://chromium-review.googlesource.com/c/chromium/src/+/5548827

* 5786325: Add Infrastructure for Hand tracking permission

https://chromium-review.googlesource.com/c/chromium/src/+/5786325

* chore: fixup patch indices

* chore: bump chromium in DEPS to 130.0.6681.0

* [Views AX] Move BrowserAccessibility* to //ui/accessibility/platform

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5520052

* chore: e patches all

* Don't have default arguments on virtual functions in render_frame_host.h

https://chromium-review.googlesource.com/c/chromium/src/+/5809399

* test: log if loadURL fails in base url test

* chore: bump chromium in DEPS to 130.0.6683.2

* chore: fix support_mixed_sandbox_with_zygote.patch

content: restore old DisableJit behavior

https://chromium-review.googlesource.com/c/chromium/src/+/5804255

* chore: update patch indices

* chore: bump chromium in DEPS to 130.0.6685.0

* Parallel process launching

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5015584

* chore: update feat_expose_documentloader_setdefersloading_on_webdocumentloader.patch

No manual changes; patch applied with fuzz 1

* chore: e patches all

* chore: bump chromium in DEPS to 130.0.6687.0

* chore: bump chromium in DEPS to 130.0.6689.0

* chore: bump chromium in DEPS to 130.0.6691.0

* chore: bump chromium in DEPS to 130.0.6693.0

* chore: update patches

* chore: bump chromium in DEPS to 130.0.6695.0

* chore: free up macos disk space as soon as possible

* 5824143: Use checked in source lists for third_party/boringssl

https://chromium-review.googlesource.com/c/chromium/src/+/5824143

* chore: update patches

* 5824122: Extensions: Add a new view type enum for developer tools contexts

https://chromium-review.googlesource.com/c/chromium/src/+/5824122

* 5806109: Option for JavaScriptExecuteRequestForTests() to ignore content settings

https://chromium-review.googlesource.com/c/chromium/src/+/5806109

* build: free up disk space on gn check too

* 5799369: [Refactoring] Make allow_http1_for_streaming_upload flags false.

https://chromium-review.googlesource.com/c/chromium/src/+/5799369

* fixup! 5015584: Parallel process launching | https://chromium-review.googlesource.com/c/chromium/src/+/5015584

* Disable failing test for short-term

See: https://github.com/electron/electron/issues/43730

* oops

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: clavin <clavin@electronjs.org>
2024-09-17 18:12:11 -07:00

168 lines
8.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Tue, 17 Aug 2021 22:42:42 -0700
Subject: feat: expose raw response headers from URLLoader
With https://chromium-review.googlesource.com/c/chromium/src/+/2856099
unfiltered response headers are only available via trusted channel
through //services/network/public/mojom/devtools_observer.mojom.
https://github.com/electron/electron/pull/30503/commits/28f4da1582d046e96cb58f3cbb590503e89dfd0d
was an attempt to use this interface but given the original response is
signalled on a different interface via URLLoaderClient::OnReceiveResponse
it is harder to sync these data from two different channels for a synchronous
event emitted on the SimpleURLLoaderWrapper::OnResponseStarted.
This patch does the minimal approach to add back the raw response
headers, moving forward we should find a way in upstream to provide
access to these headers for loader clients created on the browser process.
diff --git a/services/network/public/cpp/resource_request.cc b/services/network/public/cpp/resource_request.cc
index 28bf295032c89dc7831d341cef95d11c53ade3b3..9f82e5202f2fe275d738dcadf41c535ad9f8df94 100644
--- a/services/network/public/cpp/resource_request.cc
+++ b/services/network/public/cpp/resource_request.cc
@@ -155,6 +155,7 @@ ResourceRequest::TrustedParams& ResourceRequest::TrustedParams::operator=(
allow_cookies_from_browser = other.allow_cookies_from_browser;
include_request_cookies_with_response =
other.include_request_cookies_with_response;
+ report_raw_headers = other.report_raw_headers;
cookie_observer =
Clone(&const_cast<mojo::PendingRemote<mojom::CookieAccessObserver>&>(
other.cookie_observer));
@@ -185,6 +186,7 @@ bool ResourceRequest::TrustedParams::EqualsForTesting(
const TrustedParams& other) const {
return isolation_info.IsEqualForTesting(other.isolation_info) &&
disable_secure_dns == other.disable_secure_dns &&
+ report_raw_headers == other.report_raw_headers &&
has_user_activation == other.has_user_activation &&
allow_cookies_from_browser == other.allow_cookies_from_browser &&
include_request_cookies_with_response ==
diff --git a/services/network/public/cpp/resource_request.h b/services/network/public/cpp/resource_request.h
index 79851e979be2dbba27690e1e7807afcb252d3d23..5b766862d8c9e08ce55f328eaf9314a5d3a662c0 100644
--- a/services/network/public/cpp/resource_request.h
+++ b/services/network/public/cpp/resource_request.h
@@ -71,6 +71,7 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceRequest {
bool has_user_activation = false;
bool allow_cookies_from_browser = false;
bool include_request_cookies_with_response = false;
+ bool report_raw_headers = false;
mojo::PendingRemote<mojom::CookieAccessObserver> cookie_observer;
mojo::PendingRemote<mojom::TrustTokenAccessObserver> trust_token_observer;
mojo::PendingRemote<mojom::URLLoaderNetworkServiceObserver>
diff --git a/services/network/public/cpp/url_request_mojom_traits.cc b/services/network/public/cpp/url_request_mojom_traits.cc
index 1f18c9cbe892c24cde8d1430afa882f2d5d9879d..9817380cf1169f9c778f236a316b1928b501c68a 100644
--- a/services/network/public/cpp/url_request_mojom_traits.cc
+++ b/services/network/public/cpp/url_request_mojom_traits.cc
@@ -96,6 +96,7 @@ bool StructTraits<network::mojom::TrustedUrlRequestParamsDataView,
out->allow_cookies_from_browser = data.allow_cookies_from_browser();
out->include_request_cookies_with_response =
data.include_request_cookies_with_response();
+ out->report_raw_headers = data.report_raw_headers();
out->cookie_observer = data.TakeCookieObserver<
mojo::PendingRemote<network::mojom::CookieAccessObserver>>();
out->trust_token_observer = data.TakeTrustTokenObserver<
diff --git a/services/network/public/cpp/url_request_mojom_traits.h b/services/network/public/cpp/url_request_mojom_traits.h
index 6778aaaa46cbab86de77f75b18226a51833de450..d21a13ec46e13a6c5ed345ff99ebec25460a40af 100644
--- a/services/network/public/cpp/url_request_mojom_traits.h
+++ b/services/network/public/cpp/url_request_mojom_traits.h
@@ -76,6 +76,10 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE)
const network::ResourceRequest::TrustedParams& trusted_params) {
return trusted_params.include_request_cookies_with_response;
}
+ static bool report_raw_headers(
+ const network::ResourceRequest::TrustedParams& trusted_params) {
+ return trusted_params.report_raw_headers;
+ }
static mojo::PendingRemote<network::mojom::CookieAccessObserver>
cookie_observer(
const network::ResourceRequest::TrustedParams& trusted_params) {
diff --git a/services/network/public/mojom/url_request.mojom b/services/network/public/mojom/url_request.mojom
index 7c006ab576a03d14549f3a0c7b3fb35cf21fee0a..5cd81ab4de26bf9f174a5571d3c41fd404049a61 100644
--- a/services/network/public/mojom/url_request.mojom
+++ b/services/network/public/mojom/url_request.mojom
@@ -81,6 +81,9 @@ struct TrustedUrlRequestParams {
// client which should not be able to see them.
bool include_request_cookies_with_response = false;
+ // [Electron] Whether to provide unfiltered response headers.
+ bool report_raw_headers;
+
// Observer which should be notified when this URLRequest reads or writes
// a cookie. If this is set to non-null, the observer passed to
// URLLoaderFactory will be ignored.
diff --git a/services/network/public/mojom/url_response_head.mojom b/services/network/public/mojom/url_response_head.mojom
index 3450c15835d8b792f37764f6edc4a4560be435ef..b1034aa141d6121f8e1524fb34a28a040a280420 100644
--- a/services/network/public/mojom/url_response_head.mojom
+++ b/services/network/public/mojom/url_response_head.mojom
@@ -13,6 +13,7 @@ import "services/network/public/mojom/attribution.mojom";
import "services/network/public/mojom/fetch_api.mojom";
import "services/network/public/mojom/http_request_headers.mojom";
import "services/network/public/mojom/ip_address_space.mojom";
+import "services/network/public/mojom/http_raw_headers.mojom";
import "services/network/public/mojom/ip_endpoint.mojom";
import "services/network/public/mojom/load_timing_info.mojom";
import "services/network/public/mojom/network_param.mojom";
@@ -44,6 +45,9 @@ struct URLResponseHead {
// The response headers or NULL if the URL type does not support headers.
HttpResponseHeaders headers;
+ // Actual response headers, as obtained from the network stack.
+ array<HttpRawHeaderPair> raw_response_headers;
+
// The mime type of the response. This may be a derived value.
string mime_type;
diff --git a/services/network/url_loader.cc b/services/network/url_loader.cc
index 5cf94edd8f83f0c72bf729b8cdcddc649139d53a..2fd2912297101b3c8b0f7b3bec17917224fdd2aa 100644
--- a/services/network/url_loader.cc
+++ b/services/network/url_loader.cc
@@ -708,6 +708,7 @@ URLLoader::URLLoader(
request.trusted_params->allow_cookies_from_browser;
include_request_cookies_with_response_ =
request.trusted_params->include_request_cookies_with_response;
+ report_raw_headers_ = request.trusted_params->report_raw_headers;
}
// Store any cookies passed from the browser process to later attach them to
@@ -746,7 +747,7 @@ URLLoader::URLLoader(
&URLLoader::IsSharedDictionaryReadAllowed, base::Unretained(this)));
}
- if (devtools_request_id()) {
+ if (devtools_request_id() || report_raw_headers_) {
url_request_->SetResponseHeadersCallback(base::BindRepeating(
&URLLoader::SetRawResponseHeaders, base::Unretained(this)));
}
@@ -1719,6 +1720,19 @@ void URLLoader::OnResponseStarted(net::URLRequest* url_request, int net_error) {
}
response_ = BuildResponseHead();
+ if (raw_response_headers_ && report_raw_headers_) {
+ std::vector<network::mojom::HttpRawHeaderPairPtr> header_array;
+ size_t iterator = 0;
+ std::string name, value;
+ while (raw_response_headers_->EnumerateHeaderLines(&iterator, &name, &value)) {
+ network::mojom::HttpRawHeaderPairPtr pair =
+ network::mojom::HttpRawHeaderPair::New();
+ pair->key = name;
+ pair->value = value;
+ header_array.push_back(std::move(pair));
+ }
+ response_->raw_response_headers = std::move(header_array);
+ }
DispatchOnRawResponse();
// Parse and remove the Trust Tokens response headers, if any are expected,
diff --git a/services/network/url_loader.h b/services/network/url_loader.h
index ee904dc66eaac9b53e0fe38d06bcf084e6b49d20..1e4525d4c1c8415bccf49342d1fc1343fdce3dd8 100644
--- a/services/network/url_loader.h
+++ b/services/network/url_loader.h
@@ -670,6 +670,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) URLLoader
std::unique_ptr<ResourceScheduler::ScheduledResourceRequest>
resource_scheduler_request_handle_;
+ // Whether client requested raw headers.
+ bool report_raw_headers_ = false;
bool enable_reporting_raw_headers_ = false;
bool seen_raw_request_headers_ = false;
scoped_refptr<const net::HttpResponseHeaders> raw_response_headers_;