mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Remove net from dependencies
This commit is contained in:
parent
68472fabf8
commit
74ecc2bd64
6 changed files with 30 additions and 20 deletions
21
components/net_traits/fetch/headers.rs
Normal file
21
components/net_traits/fetch/headers.rs
Normal file
|
@ -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(", "));
|
||||
}
|
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue