mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Fix return value of concept-header-list-get to Option<Vec<u8>>
This commit is contained in:
parent
d6d48510d9
commit
b6e4e44ccf
3 changed files with 26 additions and 26 deletions
|
@ -5,11 +5,8 @@
|
|||
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());
|
||||
pub fn get_value_from_header_list(name: &str, headers: &HeaderMap) -> Option<Vec<u8>> {
|
||||
let values = headers.get_all(name).iter().map(|val| val.as_bytes());
|
||||
|
||||
// Step 1
|
||||
if values.size_hint() == (0, Some(0)) {
|
||||
|
@ -17,5 +14,5 @@ pub fn get_value_from_header_list(name: &str, headers: &HeaderMap) -> Option<Str
|
|||
}
|
||||
|
||||
// Step 2
|
||||
return Some(values.collect::<Vec<&str>>().join(", "));
|
||||
return Some(values.collect::<Vec<&[u8]>>().join(&[0x2C, 0x20][..]));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue