servo/components/net/fetch/headers.rs
shanehandley 6a3cdc47ec
Improve spec conformance around request header validation (#33418)
* fix: improve spec conformance around request header validation

Signed-off-by: Shane Handley <shanehandley@fastmail.com>

* account for additional test passes

Signed-off-by: Shane Handley <shanehandley@fastmail.com>

* fix: remove redundant .to_vec call

Signed-off-by: Shane Handley <shanehandley@fastmail.com>

---------

Signed-off-by: Shane Handley <shanehandley@fastmail.com>
2024-09-14 03:01:22 +00:00

16 lines
635 B
Rust

/* 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;
use net_traits::fetch::headers::get_decode_and_split_header_name;
/// <https://fetch.spec.whatwg.org/#determine-nosniff>
pub fn determine_nosniff(headers: &HeaderMap) -> bool {
let values = get_decode_and_split_header_name("x-content-type-options", headers);
match values {
None => false,
Some(values) => !values.is_empty() && values[0].eq_ignore_ascii_case("nosniff"),
}
}