aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/stylesheet_loader.rs
diff options
context:
space:
mode:
authorLucas Fantacuci <lucasfantacuci@gmail.com>2018-12-21 17:38:22 -0200
committerLucas Sanches Fantacuci <lucasfantacuci@gmail.com>2019-04-10 14:01:30 -0300
commit6b2be9b31de1503e90a62cc7d597dc4bd467d998 (patch)
tree869e624bc018c9a7f97d40dccea6883f66d400da /components/script/stylesheet_loader.rs
parentdd2deeabca7eeb40e6a8fe0c1ee4550d64e0c235 (diff)
downloadservo-6b2be9b31de1503e90a62cc7d597dc4bd467d998.tar.gz
servo-6b2be9b31de1503e90a62cc7d597dc4bd467d998.zip
Implementing the builder pattern for RequestInit
Diffstat (limited to 'components/script/stylesheet_loader.rs')
-rw-r--r--components/script/stylesheet_loader.rs29
1 files changed, 14 insertions, 15 deletions
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs
index 88ad87ada22..d4be597ab39 100644
--- a/components/script/stylesheet_loader.rs
+++ b/components/script/stylesheet_loader.rs
@@ -21,7 +21,9 @@ use encoding_rs::UTF_8;
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use mime::{self, Mime};
-use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestInit, RequestMode};
+use net_traits::request::{
+ CorsSettings, CredentialsMode, Destination, RequestBuilder, RequestMode,
+};
use net_traits::{
FetchMetadata, FetchResponseListener, FilteredMetadata, Metadata, NetworkError, ReferrerPolicy,
};
@@ -308,28 +310,25 @@ impl<'a> StylesheetLoader<'a> {
document.increment_script_blocking_stylesheet_count();
}
- let request = RequestInit {
- url: url.clone(),
- destination: Destination::Style,
+ let request = RequestBuilder::new(url.clone())
+ .destination(Destination::Style)
// https://html.spec.whatwg.org/multipage/#create-a-potential-cors-request
// Step 1
- mode: match cors_setting {
+ .mode(match cors_setting {
Some(_) => RequestMode::CorsMode,
None => RequestMode::NoCors,
- },
+ })
// https://html.spec.whatwg.org/multipage/#create-a-potential-cors-request
// Step 3-4
- credentials_mode: match cors_setting {
+ .credentials_mode(match cors_setting {
Some(CorsSettings::Anonymous) => CredentialsMode::CredentialsSameOrigin,
_ => CredentialsMode::Include,
- },
- origin: document.origin().immutable().clone(),
- pipeline_id: Some(self.elem.global().pipeline_id()),
- referrer_url: Some(document.url()),
- referrer_policy: referrer_policy,
- integrity_metadata: integrity_metadata,
- ..RequestInit::default()
- };
+ })
+ .origin(document.origin().immutable().clone())
+ .pipeline_id(Some(self.elem.global().pipeline_id()))
+ .referrer_url(Some(document.url()))
+ .referrer_policy(referrer_policy)
+ .integrity_metadata(integrity_metadata);
document.fetch_async(LoadType::Stylesheet(url), request, action_sender);
}