-
Notifications
You must be signed in to change notification settings - Fork 587
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
fix(util-body-length-node): calculateBodyLength for Readable stream with range #2637
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2637 +/- ##
=======================================
Coverage ? 60.62%
=======================================
Files ? 515
Lines ? 27691
Branches ? 6805
=======================================
Hits ? 16789
Misses ? 10902
Partials ? 0 Continue to review full report at Codecov.
|
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.
This change looks good, can you add a unit test?
…ith range A ReadStream created with createReadStream(file, {start: 0, end: 0}) would not be detected by this function, or would falsly just use the size of the original file at body.path. This uses the end and start numbers if present, both are inclusive so 1 is added. Inclusive according to: https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options
Note that this still doesn't handle filestreams with just an fd and no path, also doesn't handle a start but no end |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
this package has moved, opened new PR at the new site |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Description
A ReadStream created with createReadStream(file, {start: 0, end: 0}) would not be detected by this function, or would falsly just use the size of the original file at body.path. This uses the end and start numbers if present, both are inclusive so 1 is added.
Inclusive according to: https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options
Additional context
I encountered this bug while uploading a multipart file to s3
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.