Files
electron/patches/chromium/feat_expose_raw_response_headers_from_urlloader.patch
electron-roller[bot] 3e22f992b0 chore: bump chromium to 128.0.6611.0 (main) (#42779)
* chore: bump chromium in DEPS to 128.0.6577.0

* chore: bump chromium in DEPS to 128.0.6579.0

* 5675706: Reland "Reland "Reland "Reland "Add toolchains without PartitionAlloc-Everywhere for dump_syms et al""""

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

* 5668597: [PDF Ink Signatures] Prompt download menu on save when there are edits

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

* 5677014: Reland "Pull data_sharing_sdk from CIPD"

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

* chore: fixup patch indices

* chore: bump chromium in DEPS to 128.0.6581.0

* chore: bump chromium in DEPS to 128.0.6583.0

* update patches

* 5455480: [Extensions] Allow service worker requests to continue without a cert

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

* try to get some debugging output from script/push-patch.js

* chore: bump chromium in DEPS to 128.0.6585.0

* chore: bump chromium in DEPS to 128.0.6587.0

* update patches

* chore: bump chromium in DEPS to 128.0.6589.0

* more patch work

* maybe over here?

* chore: update patches

* 5673207: [HTTPS Upgrades] Disable in captive portal login webview

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

* 5636785: Extensions: WAR: manifest.json's use_dynamic_url requires a dynamic url

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

* chore: bump chromium in DEPS to 128.0.6591.0

* 5665458: Trigger WN2 page when feature is enabled

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

* update patches

* chore: bump chromium in DEPS to 128.0.6593.0

* chore: bump chromium in DEPS to 128.0.6595.0

* chore: bump chromium in DEPS to 128.0.6597.0

* (patch update) 5694586: [compile hints] Remove the usage of v8::Isolate::SetJavaScriptCompileHintsMagicEnabledCallback API
https://chromium-review.googlesource.com/c/chromium/src/+/5694586

* update patches

* 5691287: Reland "Change blink::WebKeyboardEvent to use std::array in is members"
https://chromium-review.googlesource.com/c/chromium/src/+/5691287

The code changed here is modeled after code in `content/renderer/pepper/event_conversion.cc` that was also modified in this CL, so I took the same approach.

* 5529018: Cleanup EnableWebHidOnExtensionServiceWorker flag
https://chromium-review.googlesource.com/c/chromium/src/+/5529018

* 5526324: [Code Health] Add deprecation comment for base::SupportsWeakPtr.
https://chromium-review.googlesource.com/c/chromium/src/+/5526324

Note that this CL actually does make `SupportsWeakPtr` strictly restricted to existing implementations, no new ones. We could add a patch to add ourselves to this list, but it looks like we'll have to refactor this anyways in the near future. Since the refactor seems straightforward, let's try that first.

* chore: bump chromium in DEPS to 128.0.6598.0

* chore: update patches

* 5704737: Rename ExclusiveAccessContext::GetActiveWebContents to avoid conflict
https://chromium-review.googlesource.com/c/chromium/src/+/5704737

* chore: bump chromium in DEPS to 128.0.6601.0

* chore: update patches

* Add `base::StringPiece` header includes

Chromium is working on replacing `base::StringPiece` with `std::string_view`. (See the Chromium Bug below.) They're currently running mass codemods (across many multiple changes) to replace uses of `StringPiece` with `string_view`, including removing the header include for `StringPiece` in those files. This cascades down to our files that were implicitly depending on those includes through some other include.

They're on track to eventually deprecate and remove `StringPiece` so our code should be converted, but that can be done as an upgrade follow-up task. For now, adding the header back to files that need it should suffice for minimal upgrade changes.

Chromium Bug: https://issues.chromium.org/issues/40506050

* 5702737: GlobalRequestID: Avoid unwanted inlining and narrowing int conversions
https://chromium-review.googlesource.com/c/chromium/src/+/5702737

contender for smallest commit 2024

* 5706534: Rename GlobalFeatures to GlobalDesktopFeatures.
https://chromium-review.googlesource.com/c/chromium/src/+/5706534

* 5691321: ui: remove params variants of SelectFile listener functions
https://chromium-review.googlesource.com/c/chromium/src/+/5691321

* 5714949: [Extensions] Display re-enable dialog for MV2 disabled stage
https://chromium-review.googlesource.com/c/chromium/src/+/5714949

* chore: update libc++ filenames

* patch: disable scope reuse & associated dchecks in v8 (hopefully temp, upgrade follow-up)

* fixup! Add `base::StringPiece` header includes

* update MAS patch

5710330: Add crash keys to debug NativeWidgetMacNSWindowBorderlessFrame exception
https://chromium-review.googlesource.com/c/chromium/src/+/5710330

* chore: bump chromium in DEPS to 128.0.6603.0

* chore: update patches

* 5713258: Reland "Preparation for decoupling creation/initialization of context"
https://chromium-review.googlesource.com/c/chromium/src/+/5713258

When destroying a context, it must already be shutdown, and this change enforces it with a new CHECK.

We were overriding `BrowserContextKeyedServiceFactory::BrowserContextShutdown` with an empty implementation, which differed from the default implementation that notifies the `KeyedServiceFactory` that the context has shutdown. Since we were missing this notification, the CHECK would later trip when the service was being destoryed because it was not registered as shutdown when it was shutdown.

* chore: bump chromium in DEPS to 128.0.6605.2

* chore: update patches

* refactor: linux open/save dialog patch

Our existing implementation was relying on an opaque `void* params` parameter that was passed through `ui::SelectFileDialog`.

Recently, that parameter has been getting removed:
- 5691321: ui: remove params variants of SelectFile listener functions | https://chromium-review.googlesource.com/c/chromium/src/+/5691321
- 5709097: ui: remove SelectFileDialog impl params | https://chromium-review.googlesource.com/c/chromium/src/+/5709097
- https://issues.chromium.org/issues/340178601 "reconsider SelectFileDialog"

This restructures the patch to work with mostly the same mechanics, but directly on the `ui::SelectFileDialog` object. This nets us some wins in terms of a smaller patch.

* 5713262: DevTools UI binding AIDA client event returns response
https://chromium-review.googlesource.com/c/chromium/src/+/5713262

* fixup! refactor: linux open/save dialog patch

* chore: bump chromium in DEPS to 128.0.6606.0

* chore: update patches

* fixup! refactor: linux open/save dialog patch

* chore: bump chromium in DEPS to 128.0.6607.0

* chore: update printing.patch

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

* fix: pwd error in electron-test, nan-test

fix: unshallow depot_tools before 3-way apply

* chore: e patches all

* fixup! fix: pwd error in electron-test, nan-test

* chore: bump chromium in DEPS to 128.0.6609.0

* chore: bump chromium in DEPS to 128.0.6611.0

* chore: update patches

* chore: update libcxx filenames

---------

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: Jeremy Rose <nornagon@nornagon.net>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Alice Zhao <alice@makenotion.com>
2024-07-23 08:59:44 -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 b220ca953b1dbbb1465d87f08c140026c3fee5b0..2a5bc2735c4d632b2f3e9b76dd525ba88fd04148 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 5b695d21907bdbf4b657aad91ce1cd4ef2981f43..9d524b291a2e74d2c63084922e2b0b433db08eaa 100644
--- a/services/network/public/cpp/resource_request.h
+++ b/services/network/public/cpp/resource_request.h
@@ -74,6 +74,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 478ac100dabf30cb60130a2a5f0229265a10e505..da3509da18eb634bebb25f1580c77e58256b60c9 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 6123dcab398b054b4172da86ac42ae913b046c40..d54bf69e03159c02205caa56df8193de4720d8c8 100644
--- a/services/network/public/cpp/url_request_mojom_traits.h
+++ b/services/network/public/cpp/url_request_mojom_traits.h
@@ -78,6 +78,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 4fdb324c31867ba360cc9f03d2ba432598fb7b35..397b5a3046a4d26fe41559572bca605747a32937 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 0f42a915d4755d9a7e531f5d1aba4060f77482ab..9334a3ccc919eb2420543679084e90485ba9c609 100644
--- a/services/network/url_loader.cc
+++ b/services/network/url_loader.cc
@@ -712,6 +712,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
@@ -750,7 +751,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)));
}
@@ -1713,6 +1714,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 457068609918167a0cd7714ddea922dc91e173b1..0a9dd2a04353d345e1d2a2f7d5519b4fd35025e6 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_;