-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement 0 dependency streaming multipart/form-data parser #1851
Closed
Closed
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
c3c9cf3
feat: incomplete parser
KhafraDev 438b7a3
feat: add in basic body parsing algorithm
KhafraDev 3c6f6f8
fix: remove unused body var
KhafraDev 4866b9a
fix: cleanup
KhafraDev acb3fef
feat: parse headers and emit file event
KhafraDev 2d4decd
fix: differentiate between file and field and parse header attributes…
KhafraDev ae7c177
run busboy test & support charset options
KhafraDev 1d665b9
fix: byte-by-byte receiving
KhafraDev 6ec1fd3
fix: byte-by-byte receiving
KhafraDev 119e172
fix: error on _final if parsing isn't complete
KhafraDev b902ef1
feat: implement fileSize and fieldSize limits
KhafraDev 5629f71
feat: implement files limit
KhafraDev 084a5e3
fix: parse filename base and fix filename w/ backslashes
KhafraDev 771fa9d
fix: only parse path if preservePath is false
KhafraDev 8301ce8
fix: filename parsing and filename* parsing
KhafraDev 4c40486
fix: actively parse headers, rather than lazily
KhafraDev 6c1b276
fix(finally): validate header name and fix parser issues
KhafraDev 601a4ea
fix: send leftover buffers to filestream on destroy, cleanup
KhafraDev cd6dd4b
fix: content-type headers cannot contain ;
KhafraDev 52b4b0a
enable test
KhafraDev d33ac7e
fix: content-type header with leading whitespace
KhafraDev a2bcfd6
fix: don't emit field event w/o listeners
KhafraDev 82ea7a3
fix: don't emit field event w/o listeners
KhafraDev 0d99054
feat: implement parts limit
KhafraDev 50669a6
feat: implement fields limit
KhafraDev 5dd8b45
fix: limit header length to 16 KiB
KhafraDev 13f3cb5
omg every test passes
KhafraDev ed92a82
fix: use path.win32.basename
KhafraDev dd01bd3
fix: add types & highwatermark options
KhafraDev 787b679
fix: speedup header parsing & bug fixes & nyc coverage
KhafraDev 7b15177
fix: add main test file
KhafraDev ac81520
whoops, skip tests on < v18
KhafraDev e9c8f93
apply suggestions
KhafraDev 7642b60
cleanup FileStream
KhafraDev 588d62d
fix: replace busboy in fetch
KhafraDev e21de08
perf: use collectASequenceOfCodePointsFast
KhafraDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,41 @@ | ||
'use strict' | ||
|
||
const states = { | ||
INITIAL: 0, | ||
BOUNDARY: 1, | ||
READ_HEADERS: 2, | ||
READ_BODY: 3 | ||
} | ||
|
||
const headerStates = { | ||
DEFAULT: -1, // no match | ||
FIRST: 0, | ||
SECOND: 1, | ||
THIRD: 2 | ||
} | ||
|
||
const chars = { | ||
'-': 0x2D, | ||
cr: 0x0D, | ||
lf: 0x0A, | ||
':': 0x3A, | ||
' ': 0x20, | ||
';': 0x3B, | ||
'=': 0x3D, | ||
'"': 0x22 | ||
} | ||
|
||
const emptyBuffer = Buffer.alloc(0) | ||
|
||
const crlfBuffer = Buffer.from([0x0D, 0x0A]) // \r\n | ||
|
||
const maxHeaderLength = 16 * 1024 | ||
|
||
module.exports = { | ||
states, | ||
chars, | ||
headerStates, | ||
emptyBuffer, | ||
maxHeaderLength, | ||
crlfBuffer | ||
} |
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,11 @@ | ||
'use strict' | ||
|
||
const { Readable } = require('stream') | ||
|
||
class FileStream extends Readable { | ||
_read () {} | ||
} | ||
|
||
module.exports = { | ||
FileStream | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If inputIsString you might skip the while loop and provide a fast path for this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't skip the loop entirely, we need to increase the index and check if the character matches the condition