@@ -261,6 +261,9 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
261
261
// Header names are lower-cased
262
262
this . headers [ k . toLowerCase ( ) ] = v ;
263
263
} ,
264
+ getHeader : function ( k ) {
265
+ return this . headers [ k . toLowerCase ( ) ]
266
+ } ,
264
267
headers : { }
265
268
} ;
266
269
} ) ;
@@ -404,6 +407,34 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
404
407
expect ( this . res . headers [ 'set-cookie' ] )
405
408
. to . contain ( 'hello-on-my.special.domain; domain=my.special.domain; path=/' ) ;
406
409
} ) ;
410
+
411
+ it ( 'appends set-cookies header to an existing one' , function ( ) {
412
+ var options = {
413
+ mergeCookies : true ,
414
+ } ;
415
+
416
+ this . res . setHeader ( "set-cookie" , [ 'hello; domain=my.domain; path=/' ] ) ;
417
+
418
+ httpProxy . writeHeaders ( { } , this . res , this . proxyRes , options ) ;
419
+
420
+ expect ( this . res . headers [ 'set-cookie' ] ) . to . be . an ( Array ) ;
421
+ expect ( this . res . headers [ 'set-cookie' ] ) . to . have . length ( 3 ) ;
422
+ } ) ;
423
+
424
+ it ( 'appends set-cookies header to an existing one (set-cookie is not an array)' , function ( ) {
425
+ var options = {
426
+ mergeCookies : true ,
427
+ } ;
428
+
429
+ this . proxyRes . headers = Object . assign ( { } , this . proxyRes . headers , { 'set-cookie' : 'hello1; domain=my.domain; path=/' } ) ;
430
+
431
+ this . res . setHeader ( "set-cookie" , 'hello; domain=my.domain; path=/' ) ;
432
+
433
+ httpProxy . writeHeaders ( { } , this . res , this . proxyRes , options ) ;
434
+
435
+ expect ( this . res . headers [ 'set-cookie' ] ) . to . be . an ( Array ) ;
436
+ expect ( this . res . headers [ 'set-cookie' ] ) . to . have . length ( 2 ) ;
437
+ } ) ;
407
438
} ) ;
408
439
409
440
0 commit comments