feat(entitytag): Add EntityTag comparison, make EntityTag safe to use
Adds strong and weak comparison to EntityTag as described in the RFC,
add tests for this. Make EntityTag safe to use by hiding the tag field,
this prevents users from inserting malicious values for the tag. Invalid
values can screw up header formatting and may allow to insert headers.
Introduce EntityTag::new(), .tag() and .set_tag() methods. Fix Display
trait for EntityTag. DQUOTES were missing. Remove custom formatting in ETag
header. Improve docs.
BREAKING_CHANGE: EntityTag.tag is private, use EntityTag.tag() and
EntityTag.set_tag("foobar") to access it.
This commit is contained in:
@@ -55,9 +55,9 @@ fn test_parse_header() {
|
||||
let a: IfMatch = Header::parse_header(
|
||||
[b"\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\"".to_vec()].as_ref()).unwrap();
|
||||
let b = IfMatch::EntityTags(
|
||||
vec![EntityTag{weak:false, tag: "xyzzy".to_string()},
|
||||
EntityTag{weak:false, tag: "r2d2xxxx".to_string()},
|
||||
EntityTag{weak:false, tag: "c3piozzzz".to_string()}]);
|
||||
vec![EntityTag::new(false, "xyzzy".to_string()),
|
||||
EntityTag::new(false, "r2d2xxxx".to_string()),
|
||||
EntityTag::new(false, "c3piozzzz".to_string())]);
|
||||
assert_eq!(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user