-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle offset-from-end ranges and make range handling more robust (#803)
* Handle offset-from-end ranges and make range handling more robust This PR adds support for offset-from-end ranges. An offset-from-end range header looks like "Range: bytes=-10". This returns content starting 10 bytes from the end of the content to the end of the content. The PR also updates other range responses to align with the real GCS server. Specifically, the range handling code now detects when the start of range is beyond the content bounds and returns a 416 response. Most other invalid ranges are ignored, except for a few cases where bounds are automatically adjusted. All of the cases were verified against the GCS server using requests like: ``` curl -D - https://storage.googleapis.com/marksandstrom-test/test.txt -H"Range: bytes=0-4" ``` Fixes #536. * Remove underscore prefix from parseRange function * Reformat comment * Fix off by one error and add corresponding test * Remove unused length variable in test * Apply one nit from code review Co-authored-by: fsouza <[email protected]>
- Loading branch information
Showing
2 changed files
with
156 additions
and
40 deletions.
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