feat: add Request.read(size) method for partial body reading#3164
Open
Jagdish1115 wants to merge 2 commits intoKludex:mainfrom
Open
feat: add Request.read(size) method for partial body reading#3164Jagdish1115 wants to merge 2 commits intoKludex:mainfrom
Jagdish1115 wants to merge 2 commits intoKludex:mainfrom
Conversation
Author
|
Hi, This is my first open source contribution, so I appreciate any feedback or guidance. |
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.
Summary
Adds a read(size) method to the Request class that reads exactly size bytes from the request body at a time. Currently there is no way to read a specific number of bytes from the request body. The only options are body() which loads everything into memory at once, or stream() which gives server-decided chunk sizes.
This is useful for processing large request bodies in chunks without loading everything into memory — for example, saving portions of a large body to multiple files.
Relates to #3113
Example usage:
chunk1 = await request.read(1024) # first 1KB
chunk2 = await request.read(1024) # next 1KB
chunk3 = await request.read(-1) # rest of body
Checklist