How can I use fixed-length multipart request with FormData?
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 880
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 68
Description
Discussed in https://github.com/nodejs/undici/discussions/1420
Originally posted by nwtgck May 6, 2022
Hi, I'd like to request a fixed-length multipart request. The code below requested with transfer-encoding: chunked without content-length. I assume the length of formData is statically decided.
const undici = require("undici");
(async () => {
const formData = new undici.FormData();
formData.append("myname", "myvalue");
const res = await undici.request("http://localhost:8181", {
body: formData,
});
})();
$ nc -lp 8181
PUT / HTTP/1.1
host: localhost:8181
connection: keep-alive
content-type: multipart/form-data; boundary=----formdata-undici-0.5140957512643098
transfer-encoding: chunked
64
------formdata-undici-0.5140957512643098
Content-Disposition: form-data; name="myname"
myvalue
2a
------formdata-undici-0.5140957512643098--
0
```</div>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The entry points shown are undici.FormData and undici.request; start by tracing how FormData is serialized and how request selects transfer encoding. Compare the result with the provided netcat output, and consider the work complete when a fixed-length multipart request sends Content-Length instead of transfer-encoding: chunked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100