Skip to content

add etag header #180

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

Merged
merged 1 commit into from
Dec 8, 2014
Merged

add etag header #180

merged 1 commit into from
Dec 8, 2014

Conversation

ajnirp
Copy link
Contributor

@ajnirp ajnirp commented Dec 5, 2014

fixes #170

@seanmonstar
Copy link
Member

Thanks for getting this started!

Would you be able to fill in the missing parts from the spec? You can find a link to it in the issue you referenced. Specifically, the weak indicator needs to be stores on the struct, and the value must be inside quotation marks.

@jdm
Copy link

jdm commented Dec 5, 2014

Hooray, this will make rebasing servo/servo#4117 easier :D

@ajnirp
Copy link
Contributor Author

ajnirp commented Dec 8, 2014

Build is failing, but apparently due to files not touched by this commit :/

use header::Header;

#[test]
fn test_etag() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split this up into smaller tests?

@seanmonstar
Copy link
Member

Don't worry if the tests fail for another reason. That's pretty normal with rustc changing a little every day.

// 2. in the range %x23 to %x7E, or
// 3. in the range %x80 to %xFF
fn check_slice_validity(slice: &str) -> bool {
for c in slice.bytes() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use a match statement here:

match c {
    b'\x21' | b'\x23' ... b'\x7e' | b'\x80' ... b'\xff' => (),
    _ => return false
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@seanmonstar
Copy link
Member

Excellent! This is looking really close. Also, could you remove the println!s? If you need any for debugging, use debug!(), and set the env var RUST_LOG=hyper::header::common::etag=debug to see them.

@@ -93,6 +93,9 @@ pub mod content_type;
/// Exposes the Date header.
pub mod date;

/// Exposes the Etag header.
pub mod etag;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a pub use self::etag::Etag up top?

@seanmonstar
Copy link
Member

One last nit, and I think this is good to go. Also, could you squash this into a single commit? git rebase -i master.

I was trying to decide if it'd be better to have this as an enum Etag { Weak(String), Strong(String) }, or to use a struct with a weak field, as you've done. I can't decide, so the way you've done it seems fine to me.

@ajnirp
Copy link
Contributor Author

ajnirp commented Dec 8, 2014

Squashed. Also, how do I test for tags containing chars in the x80-xff range? Apparently rust doesn't allow byte literals to exceed x7f.

@seanmonstar
Copy link
Member

Seems odd. You can do '\u0080'.

@seanmonstar
Copy link
Member

Thanks for wrapping this up! Looks great.

seanmonstar added a commit that referenced this pull request Dec 8, 2014
@seanmonstar seanmonstar merged commit 514f96e into hyperium:master Dec 8, 2014
@ajnirp
Copy link
Contributor Author

ajnirp commented Dec 8, 2014

Welcome, and thanks for the mentoring :)

@ajnirp ajnirp deleted the etag-header branch December 9, 2014 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add Etag Header
4 participants