Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add headerslist copy check #3156

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Changes from all 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
9 changes: 5 additions & 4 deletions test/fetch/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ test('set-cookie headers get cleared when passing a Request as first param', ()

assert.deepStrictEqual([...req1.headers], [['set-cookie', 'a=1']])
const req2 = new Request(req1, { headers: {} })

assert.deepStrictEqual([...req1.headers], [['set-cookie', 'a=1']])
assert.deepStrictEqual([...req2.headers], [])
assert.deepStrictEqual(req2.headers.getSetCookie(), [])
})
Expand All @@ -465,12 +465,13 @@ test('request.referrer', () => {

// https://github.com/nodejs/undici/issues/2445
test('Clone the set-cookie header when Request is passed as the first parameter and no header is passed.', (t) => {
const { strictEqual } = tspl(t, { plan: 2 })
const request = new Request('http://localhost', { headers: { 'set-cookie': 'A' } })
const request2 = new Request(request)
assert.deepStrictEqual([...request.headers], [['set-cookie', 'A']])
request2.headers.append('set-cookie', 'B')
strictEqual(request.headers.getSetCookie().join(', '), request.headers.get('set-cookie'))
strictEqual(request2.headers.getSetCookie().join(', '), request2.headers.get('set-cookie'))
assert.deepStrictEqual([...request.headers], [['set-cookie', 'A']])
assert.strictEqual(request.headers.getSetCookie().join(', '), request.headers.get('set-cookie'))
assert.strictEqual(request2.headers.getSetCookie().join(', '), request2.headers.get('set-cookie'))
})

// Tests for optimization introduced in https://github.com/nodejs/undici/pull/2456
Expand Down
Loading