@@ -59,10 +59,11 @@ async function expectNothingReceived (q) {
5959 assert . ok ( q . isEmpty ( ) )
6060}
6161
62- function writeEvents ( chunks ) {
62+ function writeEvents ( chunks , headers = { } ) {
63+ const resHeaders = Object . assign ( { } , headers , { 'Content-Type' : 'text/event-stream' } )
6364 const q = new AsyncQueue ( )
6465 chunks . forEach ( chunk => q . add ( chunk ) )
65- return TestHttpHandlers . chunkedStream ( 200 , { 'Content-Type' : 'text/event-stream' } , q )
66+ return TestHttpHandlers . chunkedStream ( 200 , resHeaders , q )
6667}
6768
6869function assertRange ( min , max , value ) {
@@ -901,13 +902,13 @@ describe('Events', function () {
901902 } )
902903 } )
903904
904- it ( 'emits open event when connection is established' , async ( ) => {
905+ it ( 'emits open event with headers when connection is established' , async ( ) => {
905906 await withServer ( async server => {
906- server . byDefault ( writeEvents ( [ ] ) )
907-
907+ server . byDefault ( writeEvents ( [ ] , { 'X-LD-EnvId' : '12345' } ) )
908908 await withEventSource ( server , async es => {
909909 const e = await waitForOpenEvent ( es )
910910 assert . equal ( e . type , 'open' )
911+ assert . equal ( e . headers [ 'x-ld-envid' ] , '12345' )
911912 } )
912913 } )
913914 } )
0 commit comments