@@ -49,7 +49,7 @@ func GetSet(t *testing.T, newStore storeFactory) {
4949
5050 res2 := httptest .NewRecorder ()
5151 req2 , _ := http .NewRequest ("GET" , "/get" , nil )
52- req2 . Header . Set ( "Cookie" , res1 . Header (). Get ( "Set-Cookie" ) )
52+ copyCookies ( req2 , res1 )
5353 r .ServeHTTP (res2 , req2 )
5454}
5555
@@ -86,12 +86,12 @@ func DeleteKey(t *testing.T, newStore storeFactory) {
8686
8787 res2 := httptest .NewRecorder ()
8888 req2 , _ := http .NewRequest ("GET" , "/delete" , nil )
89- req2 . Header . Set ( "Cookie" , res1 . Header (). Get ( "Set-Cookie" ) )
89+ copyCookies ( req2 , res1 )
9090 r .ServeHTTP (res2 , req2 )
9191
9292 res3 := httptest .NewRecorder ()
9393 req3 , _ := http .NewRequest ("GET" , "/get" , nil )
94- req3 . Header . Set ( "Cookie" , res2 . Header (). Get ( "Set-Cookie" ) )
94+ copyCookies ( req3 , res2 )
9595 r .ServeHTTP (res3 , req3 )
9696}
9797
@@ -133,12 +133,12 @@ func Flashes(t *testing.T, newStore storeFactory) {
133133
134134 res2 := httptest .NewRecorder ()
135135 req2 , _ := http .NewRequest ("GET" , "/flash" , nil )
136- req2 . Header . Set ( "Cookie" , res1 . Header (). Get ( "Set-Cookie" ) )
136+ copyCookies ( req2 , res1 )
137137 r .ServeHTTP (res2 , req2 )
138138
139139 res3 := httptest .NewRecorder ()
140140 req3 , _ := http .NewRequest ("GET" , "/check" , nil )
141- req3 . Header . Set ( "Cookie" , res2 . Header (). Get ( "Set-Cookie" ) )
141+ copyCookies ( req3 , res2 )
142142 r .ServeHTTP (res3 , req3 )
143143}
144144
@@ -178,7 +178,7 @@ func Clear(t *testing.T, newStore storeFactory) {
178178
179179 res2 := httptest .NewRecorder ()
180180 req2 , _ := http .NewRequest ("GET" , "/check" , nil )
181- req2 . Header . Set ( "Cookie" , res1 . Header (). Get ( "Set-Cookie" ) )
181+ copyCookies ( req2 , res1 )
182182 r .ServeHTTP (res2 , req2 )
183183}
184184
@@ -250,14 +250,18 @@ func Options(t *testing.T, newStore storeFactory) {
250250 req5 , _ := http .NewRequest ("GET" , "/check" , nil )
251251 r .ServeHTTP (res5 , req5 )
252252
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+ }
256258 }
257259
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+ }
261265 }
262266}
263267
@@ -306,3 +310,7 @@ func Many(t *testing.T, newStore storeFactory) {
306310 req2 .Header .Set ("Cookie" , header )
307311 r .ServeHTTP (res2 , req2 )
308312}
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