mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
* chore: bump chromium in DEPS to 109.0.5386.0 * chore: bump chromium in DEPS to 109.0.5388.0 * chore: bump chromium in DEPS to 109.0.5390.0 * chore: bump chromium in DEPS to 109.0.5392.0 * chore: bump chromium in DEPS to 109.0.5394.0 * chore: bump chromium in DEPS to 109.0.5396.0 * chore: bump chromium in DEPS to 109.0.5398.0 * chore: bump chromium in DEPS to 109.0.5400.0 * chore: update galactus * chore: bump chromium in DEPS to 109.0.5402.0 * chore: bump chromium in DEPS to 109.0.5403.0 * chore: bump chromium in DEPS to 109.0.5406.0 * chore: update patches * 4004247: Delete unused DocumentWebContentsDelegate Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4004247 * chore: bump chromium in DEPS to 109.0.5408.1 * chore: update patches * 3949284: Support pkey debug mode without pkey 0 access Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3949284 * chore: bump chromium in DEPS to 109.0.5410.0 * chore: update patches * 4000944: [Extensions] Create an API directory in //chrome/renderer/extensions Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4000944 * 3988524: Remove DocumentOverlayWindowViews | https://chromium-review.googlesource.com/c/chromium/src/+/3988524 Co-authored-by: George Xu <33054982+georgexu99@users.noreply.github.com> * chore: bump chromium in DEPS to 109.0.5412.0 * chore: update patches * 3984022: Add AddChildWindowToBrowser to DisplayClient mojo interface Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3984022 * 3957079: Delete the CryptoToken component extension and internal API Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3957079 * 4004421: Migreate ScopedAllowIO to ScopedAllowBlocking Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4004421 Co-authored-by: George Xu <georgexu99@users.noreply.github.com> * chore: bump chromium in DEPS to 109.0.5414.0 * chore: update patches * 4016180: Split PPAPI Mojo interfaces out of RenderFrameHostImpl. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4016180 * 3970838: [MPArch] Convert HostZoomMap and ZoomController off of RenderViewHost ids Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3970838 * 3997795: Don't add Chromium as a login item Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3997795 * 3993482: Remove RefCountedString::TakeString Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3993482 * 3990749: Allow forward-declared sources in base::ScopedObservation<> Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3990749 * fixup! 3957079: Delete the CryptoToken component extension and internal API * chore: bump chromium in DEPS to 110.0.5415.0 * 3883790: Move devtools_frame_token to the RenderFrameHost, to preserve RFH identity across MPArch activations. https://chromium-review.googlesource.com/c/chromium/src/+/3883790 * 4022205: Move license tooling into //tools/licenses https://chromium-review.googlesource.com/c/chromium/src/+/4022205 * chore: fixup patch indices * fixup! 3957079: Delete the CryptoToken component extension and internal API * 4008687: Finish ScopedAllowIO migration https://chromium-review.googlesource.com/c/chromium/src/+/4008687 * 3991548: Move WindowButtonOrderObserver and WindowFrameAction to LinuxUi https://chromium-review.googlesource.com/c/chromium/src/+/3991548 * fixup! 3984022: Add AddChildWindowToBrowser to DisplayClient mojo interface * 4016595: Migrate non-default ScopedObservation<> instantiations to ScopedObservationTraits<> in chrome/browser/ https://chromium-review.googlesource.com/c/chromium/src/+/4016595 * 4000481: Rename :chromedriver to :chromedriver_server Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4000481 * 4008687: Finish ScopedAllowIO migration https://chromium-review.googlesource.com/c/chromium/src/+/4008687 * 3988524: Remove DocumentOverlayWindowViews https://chromium-review.googlesource.com/c/chromium/src/+/3988524 * fixup! 3997795: Don't add Chromium as a login item * chore: fixup patches * 3996872: Plumb input event task runner to EventFactoryEvdev https://chromium-review.googlesource.com/c/chromium/src/+/3996872 * 4014994: Enable SiteIsolationForGuests by default. https://chromium-review.googlesource.com/c/chromium/src/+/4014994 * chore: adopt new thread restrictions api for //electron (#36357) chore: add thread blocking api * fixup! 4014994: Enable SiteIsolationForGuests by default. * pull parent HWND for dialogs on ui thread * chore: set parent_window in MessageBoxSettings * chore: remove redundant patch * chore: revert accidental deletion * chore: update patches Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <sattard@salesforce.com> Co-authored-by: Keeley Hammond <khammond@slack-corp.com> Co-authored-by: VerteDinde <vertedinde@electronjs.org> Co-authored-by: George Xu <33054982+georgexu99@users.noreply.github.com> Co-authored-by: George Xu <georgexu99@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Robo <hop2deep@gmail.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
159 lines
8.3 KiB
Diff
159 lines
8.3 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 65921550e62dbcd79f77192951b95991c3e904a1..c45a2a8c5adf3df78b4e4c4c0d4d945ade2a6826 100644
|
|
--- a/services/network/public/cpp/resource_request.cc
|
|
+++ b/services/network/public/cpp/resource_request.cc
|
|
@@ -234,6 +234,7 @@ bool ResourceRequest::EqualsForTesting(const ResourceRequest& request) const {
|
|
do_not_prompt_for_login == request.do_not_prompt_for_login &&
|
|
is_outermost_main_frame == request.is_outermost_main_frame &&
|
|
transition_type == request.transition_type &&
|
|
+ report_raw_headers == request.report_raw_headers &&
|
|
previews_state == request.previews_state &&
|
|
upgrade_if_insecure == request.upgrade_if_insecure &&
|
|
is_revalidating == request.is_revalidating &&
|
|
diff --git a/services/network/public/cpp/resource_request.h b/services/network/public/cpp/resource_request.h
|
|
index 8709429783fd5886fa20bcfa716a02d5d69abbaa..e0a6df45e902d086298f568d22e2c2969ee4d57d 100644
|
|
--- a/services/network/public/cpp/resource_request.h
|
|
+++ b/services/network/public/cpp/resource_request.h
|
|
@@ -160,6 +160,7 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceRequest {
|
|
bool do_not_prompt_for_login = false;
|
|
bool is_outermost_main_frame = false;
|
|
int transition_type = 0;
|
|
+ bool report_raw_headers = false;
|
|
int previews_state = 0;
|
|
bool upgrade_if_insecure = false;
|
|
bool is_revalidating = false;
|
|
diff --git a/services/network/public/cpp/url_request_mojom_traits.cc b/services/network/public/cpp/url_request_mojom_traits.cc
|
|
index 1702f66d2ec0871f15e475ae3901b48637140d59..9b4370d6c0e08662fac1892217e28f142c983576 100644
|
|
--- a/services/network/public/cpp/url_request_mojom_traits.cc
|
|
+++ b/services/network/public/cpp/url_request_mojom_traits.cc
|
|
@@ -210,6 +210,7 @@ bool StructTraits<
|
|
out->do_not_prompt_for_login = data.do_not_prompt_for_login();
|
|
out->is_outermost_main_frame = data.is_outermost_main_frame();
|
|
out->transition_type = data.transition_type();
|
|
+ out->report_raw_headers = data.report_raw_headers();
|
|
out->previews_state = data.previews_state();
|
|
out->upgrade_if_insecure = data.upgrade_if_insecure();
|
|
out->is_revalidating = data.is_revalidating();
|
|
diff --git a/services/network/public/cpp/url_request_mojom_traits.h b/services/network/public/cpp/url_request_mojom_traits.h
|
|
index af527034303f0660934d50a441fa178ddaeca475..65e0719fef13fbf730d74f9982d1b54d741a60fd 100644
|
|
--- a/services/network/public/cpp/url_request_mojom_traits.h
|
|
+++ b/services/network/public/cpp/url_request_mojom_traits.h
|
|
@@ -272,6 +272,9 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE)
|
|
static int32_t transition_type(const network::ResourceRequest& request) {
|
|
return request.transition_type;
|
|
}
|
|
+ static bool report_raw_headers(const network::ResourceRequest& request) {
|
|
+ return request.report_raw_headers;
|
|
+ }
|
|
static int32_t previews_state(const network::ResourceRequest& request) {
|
|
return request.previews_state;
|
|
}
|
|
diff --git a/services/network/public/mojom/url_request.mojom b/services/network/public/mojom/url_request.mojom
|
|
index bf3c8e3dc4d15d33118144f801b661fed667a5ba..733bb2b2b20094520c3e944288dfa01dad01ebc5 100644
|
|
--- a/services/network/public/mojom/url_request.mojom
|
|
+++ b/services/network/public/mojom/url_request.mojom
|
|
@@ -317,6 +317,9 @@ struct URLRequest {
|
|
// about this.
|
|
int32 transition_type;
|
|
|
|
+ // Whether to provide unfiltered response headers.
|
|
+ bool report_raw_headers;
|
|
+
|
|
// Whether or not to request a Preview version of the resource or let the
|
|
// browser decide.
|
|
// Note: this is an enum of type PreviewsState.
|
|
diff --git a/services/network/public/mojom/url_response_head.mojom b/services/network/public/mojom/url_response_head.mojom
|
|
index f4cbafde0cfa92e3e93f5480242025b3d5c822c4..73a7a02a224a4737c4f7a97a98a73e7f67ce3250 100644
|
|
--- a/services/network/public/mojom/url_response_head.mojom
|
|
+++ b/services/network/public/mojom/url_response_head.mojom
|
|
@@ -9,6 +9,7 @@ import "mojo/public/mojom/base/unguessable_token.mojom";
|
|
import "services/network/public/mojom/alternate_protocol_usage.mojom";
|
|
import "services/network/public/mojom/fetch_api.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";
|
|
@@ -38,6 +39,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 ce9ffb76f1b5bfd11e582bf71f9bcb6ce47676c3..b8d86763393a6f3e3b88d5078119f1a4c78960d3 100644
|
|
--- a/services/network/url_loader.cc
|
|
+++ b/services/network/url_loader.cc
|
|
@@ -479,6 +479,7 @@ URLLoader::URLLoader(
|
|
mojo::SimpleWatcher::ArmingPolicy::MANUAL,
|
|
base::SequencedTaskRunnerHandle::Get()),
|
|
per_factory_corb_state_(context.GetMutableCorbState()),
|
|
+ report_raw_headers_(request.report_raw_headers),
|
|
devtools_request_id_(request.devtools_request_id),
|
|
request_mode_(request.mode),
|
|
request_credentials_mode_(request.credentials_mode),
|
|
@@ -661,7 +662,7 @@ URLLoader::URLLoader(
|
|
url_request_->SetRequestHeadersCallback(base::BindRepeating(
|
|
&URLLoader::SetRawRequestHeadersAndNotify, base::Unretained(this)));
|
|
|
|
- if (devtools_request_id()) {
|
|
+ if (devtools_request_id() || report_raw_headers_) {
|
|
url_request_->SetResponseHeadersCallback(base::BindRepeating(
|
|
&URLLoader::SetRawResponseHeaders, base::Unretained(this)));
|
|
}
|
|
@@ -1461,6 +1462,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 96e869a882ad8829c116c542b041a3892acb4b6b..2f4898b617da4b015437fa1b1fc0c7d9787e1774 100644
|
|
--- a/services/network/url_loader.h
|
|
+++ b/services/network/url_loader.h
|
|
@@ -528,6 +528,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_;
|