mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
* chore: bump chromium in DEPS to 140.0.7296.0 * chore: update patches * 6702959: Remove OwnedByWidgetPassKey usage from content analysis dialog tests | https://chromium-review.googlesource.com/c/chromium/src/+/6702959 * 6722750: Remove un-used `stream_id` argument for `AidaCodeComplete` | https://chromium-review.googlesource.com/c/chromium/src/+/6722750 * 6696478: Reland Reland [video pip] Add fade in/out animation to controls visibility changes | https://chromium-review.googlesource.com/c/chromium/src/+/6696478 * chore: update libc++-filenames * build: explicitly include cstdlib in Boyer-Moore patch * chore: bump chromium in DEPS to 140.0.7297.0 * chore: update patches * 6729537: [FPF] Pipe flag state from the browser to the renderer | https://chromium-review.googlesource.com/c/chromium/src/+/6729537 * 6727996: [Win] Detect pre-IPC crashes in sandboxed utility processes | https://chromium-review.googlesource.com/c/chromium/src/+/6727996 * 6707182: Move wtf/cross_thread_copier*.* to "blink" namespace | https://chromium-review.googlesource.com/c/chromium/src/+/6707182 * 6730796: extensions: Extract safe browsing/telemetry methods to new client class | https://chromium-review.googlesource.com/c/chromium/src/+/6730796 * chore: bump chromium in DEPS to 140.0.7299.0 * chore: update patches * chore: update main patches * build: reset the minimum macOS SDK to 15 to match upstream This reverts commit499e987c77. * 6730215: Remove IPC_MESSAGE_LOG_ENABLED ifdef blocks. | https://chromium-review.googlesource.com/c/chromium/src/+/6730215 * 6690442: Delete ppapi/buildflags/buildflags.h | https://chromium-review.googlesource.com/c/chromium/src/+/6690442 * [wip]: 6667681: Use more binaries from clang toolchain in mac build | https://chromium-review.googlesource.com/c/chromium/src/+/6667681 * chore: bump chromium in DEPS to 140.0.7301.0 * chore: update patches * 6656309: extensions: Port proxy API to desktop Android | https://chromium-review.googlesource.com/c/chromium/src/+/6656309 * 6758510: Reland 'Move GN enable_plugins variable out of //ppapi' | https://chromium-review.googlesource.com/c/chromium/src/+/6758510 * 6701466: [Extensions] Remove NaCl arch info from Update Client URLs | https://chromium-review.googlesource.com/c/chromium/src/+/6701466 * 6735979: [FSA] Replace `request_writable` with a new enum `FileSystemAccessPermissionMode`. | https://chromium-review.googlesource.com/c/chromium/src/+/6735979 * 6712080: Reland "Turn on gender translation PAK generation everywhere" | https://chromium-review.googlesource.com/c/chromium/src/+/6712080 * 6730796: extensions: Extract safe browsing/telemetry methods to new client class | https://chromium-review.googlesource.com/c/chromium/src/+/6730796 * build: restore minimum macOS SDK to 10, restore patch This reverts commita04c579b99. * fixup! 6701466: [Extensions] Remove NaCl arch info from Update Client URLs | https://chromium-review.googlesource.com/c/chromium/src/+/6701466 * chore: correct node patches * fixup! 6667681: Use more binaries from clang toolchain in mac build | https://chromium-review.googlesource.com/c/chromium/src/+/6667681 --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Keeley Hammond <khammond@slack-corp.com> Co-authored-by: Keeley Hammond <vertedinde@electronjs.org> Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
170 lines
9.0 KiB
Diff
170 lines
9.0 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 ec76c1990b6d842e6727a1c034f831b7e43966b9..86a3bcc8fa771a333e6e269ed822af1c61369530 100644
|
|
--- a/services/network/public/cpp/resource_request.cc
|
|
+++ b/services/network/public/cpp/resource_request.cc
|
|
@@ -179,6 +179,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;
|
|
enabled_client_hints = other.enabled_client_hints;
|
|
cookie_observer =
|
|
Clone(&const_cast<mojo::PendingRemote<mojom::CookieAccessObserver>&>(
|
|
@@ -214,6 +215,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 2c6204c64a234c056b7baef43921fe24b2013e82..bed5b88fbb39c21160a0d8d4062f1ea2a84c46d1 100644
|
|
--- a/services/network/public/cpp/resource_request.h
|
|
+++ b/services/network/public/cpp/resource_request.h
|
|
@@ -77,6 +77,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;
|
|
std::optional<std::vector<network::mojom::WebClientHintsType>>
|
|
enabled_client_hints;
|
|
mojo::PendingRemote<mojom::CookieAccessObserver> cookie_observer;
|
|
diff --git a/services/network/public/cpp/url_request_mojom_traits.cc b/services/network/public/cpp/url_request_mojom_traits.cc
|
|
index 134a15fd2f3e6b7d941370741abee1698132c67b..80877a49fadd7ff2f9ad6d15e5f55eb35b2a8116 100644
|
|
--- a/services/network/public/cpp/url_request_mojom_traits.cc
|
|
+++ b/services/network/public/cpp/url_request_mojom_traits.cc
|
|
@@ -50,6 +50,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();
|
|
if (!data.ReadEnabledClientHints(&out->enabled_client_hints)) {
|
|
return false;
|
|
}
|
|
diff --git a/services/network/public/cpp/url_request_mojom_traits.h b/services/network/public/cpp/url_request_mojom_traits.h
|
|
index 39f5dcef5291dfdaf778e27c1b0152313feb77b3..9f1c16e1dfccc8787a9079095687002b7e58b4db 100644
|
|
--- a/services/network/public/cpp/url_request_mojom_traits.h
|
|
+++ b/services/network/public/cpp/url_request_mojom_traits.h
|
|
@@ -73,6 +73,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 const std::optional<std::vector<network::mojom::WebClientHintsType>>&
|
|
enabled_client_hints(
|
|
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 fc18883cc2e92bacb88d0d9906f7143607695ed8..dd7d1bd2364528ff12671dee724a4a259a78de70 100644
|
|
--- a/services/network/public/mojom/url_request.mojom
|
|
+++ b/services/network/public/mojom/url_request.mojom
|
|
@@ -88,6 +88,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;
|
|
+
|
|
// Enabled Client Hints to be evaluated quickly within the network layer
|
|
// when it receives the AcceptCHFrame.
|
|
// The value is set only if the flag is enabled.
|
|
diff --git a/services/network/public/mojom/url_response_head.mojom b/services/network/public/mojom/url_response_head.mojom
|
|
index fbc817126489e5422fd4bd11b6bd9744d648f8ff..b51b2ebe0f3291d04b0479776ddbeb1e05197f56 100644
|
|
--- a/services/network/public/mojom/url_response_head.mojom
|
|
+++ b/services/network/public/mojom/url_response_head.mojom
|
|
@@ -14,6 +14,7 @@ import "services/network/public/mojom/encoded_body_length.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/load_timing_internal_info.mojom";
|
|
@@ -52,6 +53,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 6318bfabcf5f1f72b78161954f44b2bc2ab2b08d..da73a077a944cb99f3ad41ea9f66cc6045017cb9 100644
|
|
--- a/services/network/url_loader.cc
|
|
+++ b/services/network/url_loader.cc
|
|
@@ -398,6 +398,9 @@ URLLoader::URLLoader(
|
|
mojo::SimpleWatcher::ArmingPolicy::MANUAL,
|
|
TaskRunner(request.priority)),
|
|
per_factory_orb_state_(context.GetMutableOrbState()),
|
|
+ report_raw_headers_(
|
|
+ request.trusted_params &&
|
|
+ request.trusted_params->report_raw_headers),
|
|
devtools_request_id_(request.devtools_request_id),
|
|
options_(PopulateOptions(options,
|
|
factory_params_->is_orb_enabled,
|
|
@@ -536,7 +539,7 @@ void URLLoader::SetUpUrlRequestCallbacks(
|
|
&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)));
|
|
}
|
|
@@ -1150,6 +1153,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();
|
|
|
|
ad_auction_event_record_request_helper_.HandleResponse(
|
|
diff --git a/services/network/url_loader.h b/services/network/url_loader.h
|
|
index 6ba39c957af7927b060be59f7d8837a3e2d41215..e52a276b0dd671317797104d85ccf75f5a333153 100644
|
|
--- a/services/network/url_loader.h
|
|
+++ b/services/network/url_loader.h
|
|
@@ -615,6 +615,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;
|
|
scoped_refptr<const net::HttpResponseHeaders> raw_response_headers_;
|
|
|
|
std::unique_ptr<UploadProgressTracker> upload_progress_tracker_;
|