@@ -49,7 +49,7 @@ func GetSet(t *testing.T, newStore storeFactory) {
49
49
50
50
res2 := httptest .NewRecorder ()
51
51
req2 , _ := http .NewRequest ("GET" , "/get" , nil )
52
- req2 . Header . Set ( "Cookie" , res1 . Header (). Get ( "Set-Cookie" ) )
52
+ copyCookies ( req2 , res1 )
53
53
r .ServeHTTP (res2 , req2 )
54
54
}
55
55
@@ -86,12 +86,12 @@ func DeleteKey(t *testing.T, newStore storeFactory) {
86
86
87
87
res2 := httptest .NewRecorder ()
88
88
req2 , _ := http .NewRequest ("GET" , "/delete" , nil )
89
- req2 . Header . Set ( "Cookie" , res1 . Header (). Get ( "Set-Cookie" ) )
89
+ copyCookies ( req2 , res1 )
90
90
r .ServeHTTP (res2 , req2 )
91
91
92
92
res3 := httptest .NewRecorder ()
93
93
req3 , _ := http .NewRequest ("GET" , "/get" , nil )
94
- req3 . Header . Set ( "Cookie" , res2 . Header (). Get ( "Set-Cookie" ) )
94
+ copyCookies ( req3 , res2 )
95
95
r .ServeHTTP (res3 , req3 )
96
96
}
97
97
@@ -133,12 +133,12 @@ func Flashes(t *testing.T, newStore storeFactory) {
133
133
134
134
res2 := httptest .NewRecorder ()
135
135
req2 , _ := http .NewRequest ("GET" , "/flash" , nil )
136
- req2 . Header . Set ( "Cookie" , res1 . Header (). Get ( "Set-Cookie" ) )
136
+ copyCookies ( req2 , res1 )
137
137
r .ServeHTTP (res2 , req2 )
138
138
139
139
res3 := httptest .NewRecorder ()
140
140
req3 , _ := http .NewRequest ("GET" , "/check" , nil )
141
- req3 . Header . Set ( "Cookie" , res2 . Header (). Get ( "Set-Cookie" ) )
141
+ copyCookies ( req3 , res2 )
142
142
r .ServeHTTP (res3 , req3 )
143
143
}
144
144
@@ -178,7 +178,7 @@ func Clear(t *testing.T, newStore storeFactory) {
178
178
179
179
res2 := httptest .NewRecorder ()
180
180
req2 , _ := http .NewRequest ("GET" , "/check" , nil )
181
- req2 . Header . Set ( "Cookie" , res1 . Header (). Get ( "Set-Cookie" ) )
181
+ copyCookies ( req2 , res1 )
182
182
r .ServeHTTP (res2 , req2 )
183
183
}
184
184
@@ -250,14 +250,18 @@ func Options(t *testing.T, newStore storeFactory) {
250
250
req5 , _ := http .NewRequest ("GET" , "/check" , nil )
251
251
r .ServeHTTP (res5 , req5 )
252
252
253
- s := strings .Split (res1 .Header ().Get ("Set-Cookie" ), ";" )
254
- if s [1 ] != " Path=/foo/bar/bat" {
255
- t .Error ("Error writing path with options:" , s [1 ])
253
+ for _ , c := range res1 .Header ().Values ("Set-Cookie" ) {
254
+ s := strings .Split (c , ";" )
255
+ if s [1 ] != " Path=/foo/bar/bat" {
256
+ t .Error ("Error writing path with options:" , s [1 ])
257
+ }
256
258
}
257
259
258
- s = strings .Split (res2 .Header ().Get ("Set-Cookie" ), ";" )
259
- if s [1 ] != " Domain=localhost" {
260
- t .Error ("Error writing domain with options:" , s [1 ])
260
+ for _ , c := range res2 .Header ().Values ("Set-Cookie" ) {
261
+ s := strings .Split (c , ";" )
262
+ if s [1 ] != " Domain=localhost" {
263
+ t .Error ("Error writing domain with options:" , s [1 ])
264
+ }
261
265
}
262
266
}
263
267
@@ -306,3 +310,7 @@ func Many(t *testing.T, newStore storeFactory) {
306
310
req2 .Header .Set ("Cookie" , header )
307
311
r .ServeHTTP (res2 , req2 )
308
312
}
313
+
314
+ func copyCookies (req * http.Request , res * httptest.ResponseRecorder ) {
315
+ req .Header .Set ("Cookie" , strings .Join (res .Header ().Values ("Set-Cookie" ), "; " ))
316
+ }
0 commit comments