script: Initialize all requests with clients (#41584)

In preparation for adding preload support for all requests, we need to
add relevant client information to all these entrypoints. Additionally,
for links we now also set the referrer correctly and initialize
documents. All of which are required to start loading preload
information when processing requests.

Part of #35035

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Tim van der Lippe
2025-12-30 14:10:29 +01:00
committed by GitHub
parent c394c6e65f
commit 0de7b23a7b
17 changed files with 44 additions and 22 deletions

View File

@@ -19,7 +19,7 @@ use net_traits::http_status::HttpStatus;
use net_traits::policy_container::PolicyContainer;
use net_traits::request::{
CorsSettings, CredentialsMode, Destination, InsecureRequestsPolicy, ParserMetadata,
RequestBuilder, RequestId,
RequestBuilder, RequestClient, RequestId,
};
use net_traits::{FetchMetadata, Metadata, NetworkError, ResourceFetchTiming};
use servo_url::{ImmutableOrigin, ServoUrl};
@@ -520,6 +520,7 @@ pub(crate) fn script_fetch_request(
insecure_requests_policy: InsecureRequestsPolicy,
has_trustworthy_ancestor_origin: bool,
policy_container: PolicyContainer,
client: RequestClient,
) -> RequestBuilder {
// We intentionally ignore options' credentials_mode member for classic scripts.
// The mode is initialized by create_a_potential_cors_request.
@@ -533,6 +534,7 @@ pub(crate) fn script_fetch_request(
insecure_requests_policy,
has_trustworthy_ancestor_origin,
policy_container,
client,
)
.origin(origin)
.pipeline_id(Some(pipeline_id))
@@ -564,6 +566,7 @@ fn fetch_a_classic_script(
doc.insecure_requests_policy(),
doc.has_trustworthy_ancestor_origin(),
global.policy_container(),
global.request_client(),
);
let request = doc.prepare_request(request);