Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ jobs:
set -o pipefail
make run-contract-tests | tee test-harness.log
- name: Upload Test Service Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: test-service-${{ matrix.node }}
path: test-service.log
- name: Upload Test Harness Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: test-harness-${{ matrix.node }}
Expand Down
2 changes: 1 addition & 1 deletion lib/eventsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function EventSource (url, eventSourceInitDict) {
res.removeAllListeners('end')
failOnce()
})
_emit(new Event('open'))
_emit(new Event('open', { headers: res.headers }))

// text/event-stream parser adapted from webkit's
// Source/WebCore/page/EventSource.cpp
Expand Down
11 changes: 6 additions & 5 deletions test/eventsource_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ async function expectNothingReceived (q) {
assert.ok(q.isEmpty())
}

function writeEvents (chunks) {
function writeEvents (chunks, headers = {}) {
const resHeaders = Object.assign({}, headers, { 'Content-Type': 'text/event-stream' })
const q = new AsyncQueue()
chunks.forEach(chunk => q.add(chunk))
return TestHttpHandlers.chunkedStream(200, {'Content-Type': 'text/event-stream'}, q)
return TestHttpHandlers.chunkedStream(200, resHeaders, q)
}

function assertRange (min, max, value) {
Expand Down Expand Up @@ -901,13 +902,13 @@ describe('Events', function () {
})
})

it('emits open event when connection is established', async () => {
it('emits open event with headers when connection is established', async () => {
await withServer(async server => {
server.byDefault(writeEvents([]))

server.byDefault(writeEvents([], { 'X-LD-EnvId': '12345' }))
await withEventSource(server, async es => {
const e = await waitForOpenEvent(es)
assert.equal(e.type, 'open')
assert.equal(e.headers['x-ld-envid'], '12345')
})
})
})
Expand Down