1.6.0
Add
- Add
options
argument forFormDataEncoder
constructor; - Add support for per part
Content-Length
header. It turned off by default, because it is not spec-compliant extension - the web clients does not include it. UseenableAdditionalHeaders
option to enable this header:
import {Readable} from "stream"
import {FormDataEncoder} from "form-data-encoder"
import {FormData, File} from "formdata-node"
const form = new FormData()
const file = new File(["My hovercraft is full of eels"], "file.txt", {type: "text/plain"})
form.set("field", "Some field")
form.set("file", file)
// You can pass options as the second or third argument
const encoder = new FormDataEncoder(form, {enableAdditionalHeaders: true})
Readable.from(encoder).pipe(process.stdout)
Outputs:
--form-data-boundary-ZrZBNwvvIVAsVl6f
Content-Disposition: form-data; name="field"
Content-Length: 10
Some field
--form-data-boundary-ZrZBNwvvIVAsVl6f
Content-Disposition: form-data; name="file"; filename="file.txt"
Content-Type: text/plain
Content-Length: 29
My hovercraft if full of eels
--form-data-boundary-ZrZBNwvvIVAsVl6f--
To find more information about additional headers per form-data part, see:
All changes: v1.5.4...v1.6.0