handle header with spaces before value

This commit is contained in:
Martin Algesten
2019-10-20 10:58:16 +02:00
parent e936d5ea74
commit 999653e7f3
2 changed files with 23 additions and 0 deletions

View File

@@ -94,6 +94,16 @@ impl FromStr for Header {
return Err(Error::BadHeader);
}
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
// The field value MAY be preceded by any amount of LWS, though a single SP is preferred.
let value_from = &s[index..];
let voff = match value_from.find(|c: char| !c.is_whitespace()) {
Some(n) => n,
None => 0,
};
let index = index + voff;
Ok(Header { line, index })
}
}