aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author2shiori17 <98276492+2shiori17@users.noreply.github.com>2023-03-20 22:12:50 +0900
committer2shiori17 <98276492+2shiori17@users.noreply.github.com>2023-03-20 22:12:50 +0900
commit74ecc2bd64a8f5a95e6a88318aa01b3fb3033681 (patch)
tree79ae288b2856ae838d1a134b3e16b52258b2dc30
parent68472fabf8d949e85ced3235822033ca4654ee35 (diff)
downloadservo-74ecc2bd64a8f5a95e6a88318aa01b3fb3033681.tar.gz
servo-74ecc2bd64a8f5a95e6a88318aa01b3fb3033681.zip
Remove net from dependencies
-rw-r--r--Cargo.lock1
-rw-r--r--components/net/fetch/headers.rs17
-rw-r--r--components/net_traits/fetch/headers.rs21
-rw-r--r--components/net_traits/lib.rs5
-rw-r--r--components/script/Cargo.toml1
-rw-r--r--components/script/dom/headers.rs5
6 files changed, 30 insertions, 20 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c4c15ecc754..d001700cf6f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5304,7 +5304,6 @@ dependencies = [
"mozangle",
"mozjs",
"msg",
- "net",
"net_traits",
"num-traits",
"parking_lot 0.11.2",
diff --git a/components/net/fetch/headers.rs b/components/net/fetch/headers.rs
index 652f91810c1..8a31d68738b 100644
--- a/components/net/fetch/headers.rs
+++ b/components/net/fetch/headers.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use headers::HeaderMap;
+use net_traits::fetch::headers::get_value_from_header_list;
use std::iter::Peekable;
use std::str::Chars;
@@ -155,19 +156,3 @@ fn collect_http_quoted_string(position: &mut Peekable<Chars>, extract_value: boo
// Step 6, 7
return value;
}
-
-/// <https://fetch.spec.whatwg.org/#concept-header-list-get>
-pub fn get_value_from_header_list(name: &str, headers: &HeaderMap) -> Option<String> {
- let values = headers
- .get_all(name)
- .iter()
- .map(|val| val.to_str().unwrap());
-
- // Step 1
- if values.size_hint() == (0, Some(0)) {
- return None;
- }
-
- // Step 2
- return Some(values.collect::<Vec<&str>>().join(", "));
-}
diff --git a/components/net_traits/fetch/headers.rs b/components/net_traits/fetch/headers.rs
new file mode 100644
index 00000000000..4b293b13c18
--- /dev/null
+++ b/components/net_traits/fetch/headers.rs
@@ -0,0 +1,21 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use headers::HeaderMap;
+
+/// <https://fetch.spec.whatwg.org/#concept-header-list-get>
+pub fn get_value_from_header_list(name: &str, headers: &HeaderMap) -> Option<String> {
+ let values = headers
+ .get_all(name)
+ .iter()
+ .map(|val| val.to_str().unwrap());
+
+ // Step 1
+ if values.size_hint() == (0, Some(0)) {
+ return None;
+ }
+
+ // Step 2
+ return Some(values.collect::<Vec<&str>>().join(", "));
+}
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs
index ac6ef9e3ad3..323fc9a59cb 100644
--- a/components/net_traits/lib.rs
+++ b/components/net_traits/lib.rs
@@ -53,6 +53,11 @@ pub mod image {
pub mod base;
}
+/// An implementation of the [Fetch specification](https://fetch.spec.whatwg.org/)
+pub mod fetch {
+ pub mod headers;
+}
+
/// A loading context, for context-specific sniffing, as defined in
/// <https://mimesniff.spec.whatwg.org/#context-specific-sniffing>
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml
index b5c72795a34..95b7a2ff86c 100644
--- a/components/script/Cargo.toml
+++ b/components/script/Cargo.toml
@@ -76,7 +76,6 @@ mime = "0.3.13"
mime_guess = "2.0.0"
mitochondria = "1.1.2"
msg = { path = "../msg" }
-net = { path = "../net" }
net_traits = { path = "../net_traits" }
num-traits = "0.2"
parking_lot = "0.11"
diff --git a/components/script/dom/headers.rs b/components/script/dom/headers.rs
index cd70edb96f1..aa81743fb57 100644
--- a/components/script/dom/headers.rs
+++ b/components/script/dom/headers.rs
@@ -13,8 +13,9 @@ use crate::dom::globalscope::GlobalScope;
use data_url::mime::Mime as DataUrlMime;
use dom_struct::dom_struct;
use http::header::{HeaderMap as HyperHeaders, HeaderName, HeaderValue};
-use net::fetch::headers::get_value_from_header_list;
-use net_traits::request::is_cors_safelisted_request_header;
+use net_traits::{
+ fetch::headers::get_value_from_header_list, request::is_cors_safelisted_request_header,
+};
use std::cell::Cell;
use std::str::{self, FromStr};