Release 3.3.0 (#430)
This release improves multipart form-data handling in HTTP requests, specifically ensuring that FormData is properly serialized and sent in API calls. The changes fix a bug where the form-data instance was previously string-coerced (resulting in an invalid request body), and add comprehensive regression tests to prevent this issue from recurring.
HTTP request handling improvements:
- Added a
formDataToBufferutility to serializeFormDatastreams into a buffer, ensuring multipart bodies are transmitted correctly in HTTP requests. - Updated the HTTP request logic to use the new buffer serialization for
FormData, preventing accidental string coercion and ensuring the correctContent-Typeand body format. - Enhanced header generation to merge headers from
FormDatainstances when present, ensuring the multipart boundary is set correctly. - Imported Node's
Writablestream to support the new buffer serialization logic.
Testing and regression coverage:
- Improved and expanded tests in
test/files/files.jsto verify that multipart requests include the correct fields and headers, and added a regression test for issue #418 to ensure the bug does not reoccur. [1] [2]