-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support array of headers in WrapHandler (#3941)
* support array of headers in WrapHandler * fixup
- Loading branch information
Showing
3 changed files
with
37 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict' | ||
|
||
const { test } = require('node:test') | ||
const { createServer } = require('node:http') | ||
const { once } = require('node:events') | ||
const assert = require('node:assert') | ||
const { Agent, RetryAgent, request } = require('..') | ||
|
||
// https://github.com/nodejs/undici/issues/3934 | ||
test('WrapHandler works with multiple header values', async (t) => { | ||
const server = createServer(async (_req, res) => { | ||
const headers = [ | ||
['set-cookie', 'a'], | ||
['set-cookie', 'b'], | ||
['set-cookie', 'c'] | ||
] | ||
res.writeHead(200, headers) | ||
res.end() | ||
}).listen(0) | ||
|
||
await once(server, 'listening') | ||
t.after(() => server.close()) | ||
|
||
const agent = new Agent() | ||
const retryAgent = new RetryAgent(agent) | ||
|
||
const { | ||
headers | ||
} = await request(`http://localhost:${server.address().port}`, { dispatcher: retryAgent }) | ||
|
||
assert.deepStrictEqual(headers['set-cookie'], ['a', 'b', 'c']) | ||
}) |