Skip to content

Commit 799698c

Browse files
committed
feat(headers): re-export CookiePair and CookieJar
1 parent 81d42c9 commit 799698c

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

src/header/common/cookie.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
use header::{Header, HeaderFormat};
1+
use header::{Header, HeaderFormat, CookiePair, CookieJar};
22
use std::fmt::{self, Display};
33
use std::str::from_utf8;
44

5-
use cookie::Cookie as CookiePair;
6-
use cookie::CookieJar;
7-
85
/// `Cookie` header, defined in [RFC6265](http://tools.ietf.org/html/rfc6265#section-5.4)
96
///
107
/// If the user agent does attach a Cookie header field to an HTTP

src/header/common/set_cookie.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
use header::{Header, HeaderFormat};
1+
use header::{Header, HeaderFormat, CookiePair, CookieJar};
22
use std::fmt::{self, Display};
33
use std::str::from_utf8;
44

5-
use cookie::Cookie;
6-
use cookie::CookieJar;
75

86
/// `Set-Cookie` header, defined [RFC6265](http://tools.ietf.org/html/rfc6265#section-4.1)
97
///
@@ -80,9 +78,9 @@ use cookie::CookieJar;
8078
/// # }
8179
/// ```
8280
#[derive(Clone, PartialEq, Debug)]
83-
pub struct SetCookie(pub Vec<Cookie>);
81+
pub struct SetCookie(pub Vec<CookiePair>);
8482

85-
__hyper__deref!(SetCookie => Vec<Cookie>);
83+
__hyper__deref!(SetCookie => Vec<CookiePair>);
8684

8785
impl Header for SetCookie {
8886
fn header_name() -> &'static str {
@@ -142,7 +140,7 @@ impl SetCookie {
142140
#[test]
143141
fn test_parse() {
144142
let h = Header::parse_header(&[b"foo=bar; HttpOnly".to_vec()][..]);
145-
let mut c1 = Cookie::new("foo".to_owned(), "bar".to_owned());
143+
let mut c1 = CookiePair::new("foo".to_owned(), "bar".to_owned());
146144
c1.httponly = true;
147145

148146
assert_eq!(h.ok(), Some(SetCookie(vec![c1])));
@@ -152,10 +150,10 @@ fn test_parse() {
152150
fn test_fmt() {
153151
use header::Headers;
154152

155-
let mut cookie = Cookie::new("foo".to_owned(), "bar".to_owned());
153+
let mut cookie = CookiePair::new("foo".to_owned(), "bar".to_owned());
156154
cookie.httponly = true;
157155
cookie.path = Some("/p".to_owned());
158-
let cookies = SetCookie(vec![cookie, Cookie::new("baz".to_owned(), "quux".to_owned())]);
156+
let cookies = SetCookie(vec![cookie, CookiePair::new("baz".to_owned(), "quux".to_owned())]);
159157
let mut headers = Headers::new();
160158
headers.set(cookies);
161159

@@ -167,7 +165,7 @@ fn test_fmt() {
167165
#[test]
168166
fn cookie_jar() {
169167
let jar = CookieJar::new(b"secret");
170-
let cookie = Cookie::new("foo".to_owned(), "bar".to_owned());
168+
let cookie = CookiePair::new("foo".to_owned(), "bar".to_owned());
171169
jar.add(cookie);
172170

173171
let cookies = SetCookie::from_cookie_jar(&jar);
@@ -176,5 +174,5 @@ fn cookie_jar() {
176174
cookies.apply_to_cookie_jar(&mut new_jar);
177175

178176
assert_eq!(jar.find("foo"), new_jar.find("foo"));
179-
assert_eq!(jar.iter().collect::<Vec<Cookie>>(), new_jar.iter().collect::<Vec<Cookie>>());
177+
assert_eq!(jar.iter().collect::<Vec<CookiePair>>(), new_jar.iter().collect::<Vec<CookiePair>>());
180178
}

src/header/shared/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
pub use self::charset::Charset;
2+
pub use cookie::Cookie as CookiePair;
3+
pub use cookie::CookieJar;
24
pub use self::encoding::Encoding;
35
pub use self::entity::EntityTag;
46
pub use self::httpdate::HttpDate;

0 commit comments

Comments
 (0)