fix: allow multipart/form-data boundary to end with a newline#5660
Merged
ogabrielluiz merged 1 commit intolangflow-ai:mainfrom Jan 21, 2025
Merged
fix: allow multipart/form-data boundary to end with a newline#5660ogabrielluiz merged 1 commit intolangflow-ai:mainfrom
ogabrielluiz merged 1 commit intolangflow-ai:mainfrom
Conversation
The RFC 7578 spec for multipart/form-data requests does not require the body of a request to end with a CRLF, only that each section begins with a CRLF. While many clients implement multipart requests with the trailing CRLF, the implementation for fetch in Node.js version 22 and below does not. This caused my a good number of hours debugging! It does turn out that in September 2024 the Node.js fetch implementation added the CRLF (nodejs/undici#3625), though this hasn't made it to a Node.js release yet. This change allows the boundary to end with a newline or not, as long as the boundary is followed by the end of the request body.
ef9dea6 to
08fd912
Compare
CodSpeed Performance ReportMerging #5660 will improve performances by 32.73%Comparing Summary
Benchmarks breakdown
|
philnash
added a commit
to langflow-ai/langflow-client-ts
that referenced
this pull request
Jan 14, 2025
This required installing undici, which is the more frequently updated version of Node's built in fetch. This is because Langflow doesn't consider a multipart/form-data request that doesn't end with a CRLF to be a valid request and the current version of undici embedded in Node doesn't add the CRLF. I've made a PR to Langflow to relax this requirement (langflow-ai/langflow#5660), and version 7 of undici has been merged to the Node main branch but not yet released in any version, at the time of writing.
ogabrielluiz
approved these changes
Jan 21, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The RFC 7578 spec for multipart/form-data requests does not require the body of a request to end with a CRLF, only that each section begins with a CRLF. While many clients implement multipart requests with the trailing CRLF, the implementation for fetch in Node.js version 22 and below does not.
This caused my a good number of hours debugging!
It does turn out that in September 2024 the Node.js fetch implementation added the CRLF, though this hasn't made it to a Node.js release yet.
This change allows the boundary to end with a CRLF or not, as long as the boundary is followed by the end of the request body.