Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/common/if_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,29 @@ impl From<ETag> for IfMatch {

#[cfg(test)]
mod tests {
use super::super::test_decode;
use super::*;

#[test]
fn test_empty() {
assert_eq!(test_decode::<IfMatch>(&[]), None);
}

#[test]
fn test_invalid() {
assert_eq!(test_decode::<IfMatch>(&[""]), None);
assert_eq!(test_decode::<IfMatch>(&[" "]), None);
assert_eq!(test_decode::<IfMatch>(&["foo"]), None);
}

#[test]
fn test_valid() {
assert_eq!(
test_decode::<IfMatch>(&["\"foo\""]),
Some(IfMatch::from(ETag::from_static("\"foo\"")))
);
}

#[test]
fn is_any() {
assert!(IfMatch::any().is_any());
Expand Down
3 changes: 3 additions & 0 deletions src/util/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ impl super::TryFromValues for EntityTagRange {
if flat.value == "*" {
Ok(EntityTagRange::Any)
} else {
for tag in flat.iter() {
EntityTag::parse(tag.as_bytes()).ok_or_else(::Error::invalid)?;
}
Ok(EntityTagRange::Tags(flat))
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/flat_csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ impl<Sep: Separator> TryFromValues for FlatCsv<Sep> {
where
I: Iterator<Item = &'i HeaderValue>,
{
let mut values = values.peekable();
values.peek().ok_or_else(::Error::invalid)?;

let flat = values.collect();
Ok(flat)
}
Expand Down