-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
append crlf to formdata body (#3625)
* append crlf to formdata body * fixup! v18
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict' | ||
|
||
const assert = require('node:assert') | ||
const { File } = require('node:buffer') | ||
const { test } = require('node:test') | ||
const { once } = require('node:events') | ||
const { createServer } = require('node:http') | ||
const { fetch, FormData } = require('../..') | ||
|
||
// https://github.com/nodejs/undici/issues/3624 | ||
test('crlf is appended to formdata body (issue #3624)', async (t) => { | ||
const server = createServer((req, res) => { | ||
req.pipe(res) | ||
}).listen(0) | ||
|
||
t.after(server.close.bind(server)) | ||
await once(server, 'listening') | ||
|
||
const fd = new FormData() | ||
fd.set('a', 'b') | ||
fd.set('c', new File(['d'], 'd.txt.exe'), 'd.txt.exe') | ||
|
||
const response = await fetch(`http://localhost:${server.address().port}`, { | ||
body: fd, | ||
method: 'POST' | ||
}) | ||
|
||
assert((await response.text()).endsWith('\r\n')) | ||
}) |