Remove net from dependencies

This commit is contained in:
2shiori17 2023-03-20 22:12:50 +09:00
parent 68472fabf8
commit 74ecc2bd64
6 changed files with 30 additions and 20 deletions

View file

@ -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(", "));
}