Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev committed Feb 9, 2024
1 parent e35a5c7 commit 10bdfa3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/issue-2065.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const { test } = require('tap')
const { createServer } = require('node:http')
const { once } = require('node:events')
const { openAsBlob } = require('node:fs')
const { File, FormData, request } = require('..')

test('undici.request with a FormData body should set content-length header', async (t) => {
Expand All @@ -22,3 +23,21 @@ test('undici.request with a FormData body should set content-length header', asy
body
})
})

test('undici.request with a FormData stream value should set transfer-encoding header', { skip: !openAsBlob }, async (t) => {
const server = createServer((req, res) => {
t.ok(req.headers['content-type'].startsWith('multipart/form-data'))
res.end()
}).listen(0)

t.teardown(server.close.bind(server))
await once(server, 'listening')

const body = new FormData()
body.set('file', await openAsBlob(__filename), 'streamfile')

await request(`http://localhost:${server.address().port}`, {
method: 'POST',
body
})
})

0 comments on commit 10bdfa3

Please sign in to comment.