1
- use header:: { Header , HeaderFormat } ;
1
+ use header:: { Header , HeaderFormat , CookiePair , CookieJar } ;
2
2
use std:: fmt:: { self , Display } ;
3
3
use std:: str:: from_utf8;
4
4
5
- use cookie:: Cookie ;
6
- use cookie:: CookieJar ;
7
5
8
6
/// `Set-Cookie` header, defined [RFC6265](http://tools.ietf.org/html/rfc6265#section-4.1)
9
7
///
@@ -80,9 +78,9 @@ use cookie::CookieJar;
80
78
/// # }
81
79
/// ```
82
80
#[ derive( Clone , PartialEq , Debug ) ]
83
- pub struct SetCookie ( pub Vec < Cookie > ) ;
81
+ pub struct SetCookie ( pub Vec < CookiePair > ) ;
84
82
85
- __hyper__deref ! ( SetCookie => Vec <Cookie >) ;
83
+ __hyper__deref ! ( SetCookie => Vec <CookiePair >) ;
86
84
87
85
impl Header for SetCookie {
88
86
fn header_name ( ) -> & ' static str {
@@ -142,7 +140,7 @@ impl SetCookie {
142
140
#[ test]
143
141
fn test_parse ( ) {
144
142
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 ( ) ) ;
146
144
c1. httponly = true ;
147
145
148
146
assert_eq ! ( h. ok( ) , Some ( SetCookie ( vec![ c1] ) ) ) ;
@@ -152,10 +150,10 @@ fn test_parse() {
152
150
fn test_fmt ( ) {
153
151
use header:: Headers ;
154
152
155
- let mut cookie = Cookie :: new ( "foo" . to_owned ( ) , "bar" . to_owned ( ) ) ;
153
+ let mut cookie = CookiePair :: new ( "foo" . to_owned ( ) , "bar" . to_owned ( ) ) ;
156
154
cookie. httponly = true ;
157
155
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( ) ) ] ) ;
159
157
let mut headers = Headers :: new ( ) ;
160
158
headers. set ( cookies) ;
161
159
@@ -167,7 +165,7 @@ fn test_fmt() {
167
165
#[ test]
168
166
fn cookie_jar ( ) {
169
167
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 ( ) ) ;
171
169
jar. add ( cookie) ;
172
170
173
171
let cookies = SetCookie :: from_cookie_jar ( & jar) ;
@@ -176,5 +174,5 @@ fn cookie_jar() {
176
174
cookies. apply_to_cookie_jar ( & mut new_jar) ;
177
175
178
176
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 >>( ) ) ;
180
178
}
0 commit comments