summaryrefslogtreecommitdiffstats
path: root/test/fetch/issue-2318.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/fetch/issue-2318.js')
-rw-r--r--test/fetch/issue-2318.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/fetch/issue-2318.js b/test/fetch/issue-2318.js
new file mode 100644
index 0000000..e4f610d
--- /dev/null
+++ b/test/fetch/issue-2318.js
@@ -0,0 +1,25 @@
+'use strict'
+
+const { test } = require('tap')
+const { once } = require('events')
+const { createServer } = require('http')
+const { fetch } = require('../..')
+
+test('Undici overrides user-provided `Host` header', async (t) => {
+ t.plan(1)
+
+ const server = createServer((req, res) => {
+ t.equal(req.headers.host, `localhost:${server.address().port}`)
+
+ res.end()
+ }).listen(0)
+
+ t.teardown(server.close.bind(server))
+ await once(server, 'listening')
+
+ await fetch(`http://localhost:${server.address().port}`, {
+ headers: {
+ host: 'www.idk.org'
+ }
+ })
+})