Consider FileResponse.chunk_size when handling multiple ranges#2703
Merged
Consider FileResponse.chunk_size when handling multiple ranges#2703
FileResponse.chunk_size when handling multiple ranges#2703Conversation
Kludex
commented
Sep 23, 2024
starlette/responses.py
Outdated
| chunk = await file.read(min(self.chunk_size, end - start)) | ||
| start += len(chunk) | ||
| await send({"type": "http.response.body", "body": chunk, "more_body": True}) | ||
| if len(chunk) < self.chunk_size or start >= end: |
Owner
Author
There was a problem hiding this comment.
Is the len(chunk) < self.chunk_size necessary?
I'm too tired, I'll check tomorrow. Just leaving my own comment here.
Contributor
There was a problem hiding this comment.
it can be mathematically deduced that is not required
Contributor
There was a problem hiding this comment.
Yes, there is no need to check once len(chunk) < self.chunk_size
Owner
Author
|
How do I have a different behavior in Python versions with this diff? 🤔 |
Owner
Author
Coverage is not able to understand that the |
Kludex
commented
Sep 23, 2024
Kludex
commented
Sep 24, 2024
frostming
reviewed
Sep 24, 2024
Co-authored-by: Frost Ming <mianghong@gmail.com>
Owner
Author
|
@abersheeran @frostming anything else here, or we are good? |
Contributor
|
lgtm |
FileResponse.chunk_size on multiple rangesFileResponse.chunk_size when handling multiple ranges
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.
cc @frostming