forked from nodejs/undici
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissue-2021.js
More file actions
33 lines (27 loc) · 821 Bytes
/
issue-2021.js
File metadata and controls
33 lines (27 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict'
const { test } = require('node:test')
const assert = require('node:assert')
const { once } = require('events')
const { createServer } = require('http')
const { fetch } = require('../..')
// https://github.com/nodejs/undici/issues/2021
test('content-length header is removed on redirect', async (t) => {
const server = createServer((req, res) => {
if (req.url === '/redirect') {
res.writeHead(302, { Location: '/redirect2' })
res.end()
return
}
res.end()
}).listen(0).unref()
t.after(server.close.bind(server))
await once(server, 'listening')
const body = 'a+b+c'
await assert.doesNotReject(fetch(`http://localhost:${server.address().port}/redirect`, {
method: 'POST',
body,
headers: {
'content-length': Buffer.byteLength(body)
}
}))
})