diff --git a/Cargo.toml b/Cargo.toml index 650f5313fe..84d4d7b276 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,11 +25,11 @@ unicase = "1.0" url = "0.2" [dependencies.cookie] -version = "0.1" +version = "0.2" default-features = false [dependencies.openssl] -version = "0.6.4" +version = "0.7" optional = true [dependencies.solicit] diff --git a/src/header/common/cookie.rs b/src/header/common/cookie.rs index 904a1b5ac1..e6e8261ee9 100644 --- a/src/header/common/cookie.rs +++ b/src/header/common/cookie.rs @@ -1,10 +1,7 @@ -use header::{Header, HeaderFormat}; +use header::{Header, HeaderFormat, CookiePair, CookieJar}; use std::fmt::{self, Display}; use std::str::from_utf8; -use cookie::Cookie as CookiePair; -use cookie::CookieJar; - /// `Cookie` header, defined in [RFC6265](http://tools.ietf.org/html/rfc6265#section-5.4) /// /// If the user agent does attach a Cookie header field to an HTTP diff --git a/src/header/common/set_cookie.rs b/src/header/common/set_cookie.rs index ba095615ca..88ac424c00 100644 --- a/src/header/common/set_cookie.rs +++ b/src/header/common/set_cookie.rs @@ -1,9 +1,7 @@ -use header::{Header, HeaderFormat}; +use header::{Header, HeaderFormat, CookiePair, CookieJar}; use std::fmt::{self, Display}; use std::str::from_utf8; -use cookie::Cookie; -use cookie::CookieJar; /// `Set-Cookie` header, defined [RFC6265](http://tools.ietf.org/html/rfc6265#section-4.1) /// @@ -80,9 +78,9 @@ use cookie::CookieJar; /// # } /// ``` #[derive(Clone, PartialEq, Debug)] -pub struct SetCookie(pub Vec); +pub struct SetCookie(pub Vec); -__hyper__deref!(SetCookie => Vec); +__hyper__deref!(SetCookie => Vec); impl Header for SetCookie { fn header_name() -> &'static str { @@ -142,7 +140,7 @@ impl SetCookie { #[test] fn test_parse() { let h = Header::parse_header(&[b"foo=bar; HttpOnly".to_vec()][..]); - let mut c1 = Cookie::new("foo".to_owned(), "bar".to_owned()); + let mut c1 = CookiePair::new("foo".to_owned(), "bar".to_owned()); c1.httponly = true; assert_eq!(h.ok(), Some(SetCookie(vec![c1]))); @@ -152,22 +150,22 @@ fn test_parse() { fn test_fmt() { use header::Headers; - let mut cookie = Cookie::new("foo".to_owned(), "bar".to_owned()); + let mut cookie = CookiePair::new("foo".to_owned(), "bar".to_owned()); cookie.httponly = true; cookie.path = Some("/p".to_owned()); - let cookies = SetCookie(vec![cookie, Cookie::new("baz".to_owned(), "quux".to_owned())]); + let cookies = SetCookie(vec![cookie, CookiePair::new("baz".to_owned(), "quux".to_owned())]); let mut headers = Headers::new(); headers.set(cookies); assert_eq!( &headers.to_string()[..], - "Set-Cookie: foo=bar; HttpOnly; Path=/p\r\nSet-Cookie: baz=quux; Path=/\r\n"); + "Set-Cookie: foo=bar; HttpOnly; Path=/p\r\nSet-Cookie: baz=quux\r\n"); } #[test] fn cookie_jar() { let jar = CookieJar::new(b"secret"); - let cookie = Cookie::new("foo".to_owned(), "bar".to_owned()); + let cookie = CookiePair::new("foo".to_owned(), "bar".to_owned()); jar.add(cookie); let cookies = SetCookie::from_cookie_jar(&jar); @@ -176,5 +174,5 @@ fn cookie_jar() { cookies.apply_to_cookie_jar(&mut new_jar); assert_eq!(jar.find("foo"), new_jar.find("foo")); - assert_eq!(jar.iter().collect::>(), new_jar.iter().collect::>()); + assert_eq!(jar.iter().collect::>(), new_jar.iter().collect::>()); } diff --git a/src/header/shared/mod.rs b/src/header/shared/mod.rs index d2c2355bc0..272b2ede93 100644 --- a/src/header/shared/mod.rs +++ b/src/header/shared/mod.rs @@ -1,4 +1,6 @@ pub use self::charset::Charset; +pub use cookie::Cookie as CookiePair; +pub use cookie::CookieJar; pub use self::encoding::Encoding; pub use self::entity::EntityTag; pub use self::httpdate::HttpDate; diff --git a/src/http/h2.rs b/src/http/h2.rs index 136bf80c9c..5e4d551e93 100644 --- a/src/http/h2.rs +++ b/src/http/h2.rs @@ -661,8 +661,8 @@ mod tests { let h2headers = prepare_headers(headers); assert_eq!(vec![ - (b"set-cookie".to_vec(), b"foo=bar; Path=/".to_vec()), - (b"set-cookie".to_vec(), b"baz=quux; Path=/".to_vec()), + (b"set-cookie".to_vec(), b"foo=bar".to_vec()), + (b"set-cookie".to_vec(), b"baz=quux".to_vec()), ], h2headers); } @@ -700,8 +700,8 @@ mod tests { #[test] fn test_http2_parse_headers_with_set_cookie() { let h2headers = vec![ - (b"set-cookie".to_vec(), b"foo=bar; Path=/".to_vec()), - (b"set-cookie".to_vec(), b"baz=quux; Path=/".to_vec()), + (b"set-cookie".to_vec(), b"foo=bar".to_vec()), + (b"set-cookie".to_vec(), b"baz=quux".to_vec()), ]; let expected = header::SetCookie(vec![ cookie::Cookie::new("foo".to_owned(), "bar".to_owned()),