From 6b2be9b31de1503e90a62cc7d597dc4bd467d998 Mon Sep 17 00:00:00 2001 From: Lucas Fantacuci Date: Fri, 21 Dec 2018 17:38:22 -0200 Subject: Implementing the builder pattern for RequestInit --- components/script/script_thread.rs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'components/script/script_thread.rs') diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 28a9a52566f..135e05abd0b 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -110,7 +110,7 @@ use msg::constellation_msg::{BrowsingContextId, HistoryStateId, PipelineId}; use msg::constellation_msg::{HangAnnotation, MonitoredComponentId, MonitoredComponentType}; use msg::constellation_msg::{PipelineNamespace, TopLevelBrowsingContextId}; use net_traits::image_cache::{ImageCache, PendingImageResponse}; -use net_traits::request::{CredentialsMode, Destination, RedirectMode, RequestInit}; +use net_traits::request::{CredentialsMode, Destination, RedirectMode, RequestBuilder}; use net_traits::storage_thread::StorageType; use net_traits::{FetchMetadata, FetchResponseListener, FetchResponseMsg}; use net_traits::{ @@ -3327,21 +3327,18 @@ impl ScriptThread { /// argument until a notification is received that the fetch is complete. fn pre_page_load(&self, mut incomplete: InProgressLoad, load_data: LoadData) { let id = incomplete.pipeline_id.clone(); - let req_init = RequestInit { - url: load_data.url.clone(), - method: load_data.method, - destination: Destination::Document, - credentials_mode: CredentialsMode::Include, - use_url_credentials: true, - pipeline_id: Some(id), - referrer_url: load_data.referrer_url, - referrer_policy: load_data.referrer_policy, - headers: load_data.headers, - body: load_data.data, - redirect_mode: RedirectMode::Manual, - origin: incomplete.origin.immutable().clone(), - ..RequestInit::default() - }; + let req_init = RequestBuilder::new(load_data.url.clone()) + .method(load_data.method) + .destination(Destination::Document) + .credentials_mode(CredentialsMode::Include) + .use_url_credentials(true) + .pipeline_id(Some(id)) + .referrer_url(load_data.referrer_url) + .referrer_policy(load_data.referrer_policy) + .headers(load_data.headers) + .body(load_data.data) + .redirect_mode(RedirectMode::Manual) + .origin(incomplete.origin.immutable().clone()); let context = ParserContext::new(id, load_data.url); self.incomplete_parser_contexts -- cgit v1.2.3