-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(entitytag): Add EntityTag comparison, make EntityTag safe to use #409
Conversation
Thanks for contributing! Unfortunately, I'm here to tell you there were the following style issues with your Pull Request:
Guidelines are available at https://github.com/hyperium/hyper/blob/master/CONTRIBUTING.md This message was auto-generated by https://gitcop.com |
/// Set the tag. | ||
/// # Panics | ||
/// If the tag contains invalid characters. | ||
pub fn set_tag(&mut self, tagslice: &str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems odd to me for a setter to ask for a reference. I'd expect either a String
, or Into<String>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will use It looks like Into<String>
.Into<String>
won't work yet, so I use String
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's OK. Switching to Into<String>
should be a non-breaking change.
@pyfisch This is superb! Just one minor comment. |
/// Constructs a new EntityTag. | ||
/// # Panics | ||
/// If the tag contains invalid characters. | ||
pub fn new(weak: bool, tagslice: &str) -> EntityTag { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the same here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes.
Specifically, the only way to pass a &str
is to have a static str, or they need to create a String
. Since they have already allocated a String
in order pass a reference, it's wasteful to allocate a new String, especially since they likely just threw away the original they made.
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.
Updated code. |
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.