refactor(headers): errors for parse_header
Header::parse_header() returns now a hyper Result instead of an option this will enable more precise Error messages in the future, currently most failures are reported as ::Error::Header. BREAKING CHANGE: parse_header returns Result instead of Option, related code did also change
This commit is contained in:
@@ -26,7 +26,7 @@ impl Header for Expect {
|
||||
"Expect"
|
||||
}
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Expect> {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> ::Result<Expect> {
|
||||
if raw.len() == 1 {
|
||||
let text = unsafe {
|
||||
// safe because:
|
||||
@@ -38,12 +38,12 @@ impl Header for Expect {
|
||||
str::from_utf8_unchecked(raw.get_unchecked(0))
|
||||
};
|
||||
if UniCase(text) == EXPECT_CONTINUE {
|
||||
Some(Expect::Continue)
|
||||
Ok(Expect::Continue)
|
||||
} else {
|
||||
None
|
||||
Err(::Error::Header)
|
||||
}
|
||||
} else {
|
||||
None
|
||||
Err(::Error::Header)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user