[GH-ISSUE #536] Add support for negative offset #101

Closed
opened 2026-03-03 12:08:18 +03:00 by kerem · 1 comment
Owner

Originally created by @Leavrth on GitHub (Jul 15, 2021).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/536

It seems that negative offset is not considered, such as range=-10- which means NewRangeReader(ctx, -10, -1).
github.com/fsouza/fake-gcs-server@5a7dc5a5a6/fakestorage/object.go (L578-L599)

It can be seen in Example(LastNBytes) in https://pkg.go.dev/cloud.google.com/go/storage#ObjectHandle.NewRangeReader

Originally created by @Leavrth on GitHub (Jul 15, 2021). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/536 It seems that negative offset is not considered, such as `range=-10-` which means `NewRangeReader(ctx, -10, -1)`. https://github.com/fsouza/fake-gcs-server/blob/5a7dc5a5a672ab1b61ed7a9d4180614d60245975/fakestorage/object.go#L578-L599 It can be seen in `Example(LastNBytes)` in https://pkg.go.dev/cloud.google.com/go/storage#ObjectHandle.NewRangeReader
kerem 2026-03-03 12:08:18 +03:00
Author
Owner

@dnerdy commented on GitHub (Jun 1, 2022):

I'd like to fix this. Note that I don't believe Range: bytes=-10- is a valid range. A range with an offset from the end of the content looks like Range: bytes=-10. I also noticed it's possible to cause fake-gcs-server to panic by requesting an out-of-bound range. GCS returns a 416 when the range start is past the end of the content, and ignores other invalid ranges (i.e. it returns a 200 response with the entire content).

<!-- gh-comment-id:1144160213 --> @dnerdy commented on GitHub (Jun 1, 2022): I'd like to fix this. Note that I don't believe `Range: bytes=-10-` is a valid range. A range with an offset from the end of the content looks like `Range: bytes=-10`. I also noticed it's possible to cause fake-gcs-server to panic by requesting an out-of-bound range. GCS returns a 416 when the range start is past the end of the content, and ignores other invalid ranges (i.e. it returns a 200 response with the entire content).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#101
No description provided.