Skip to content

Commit

Permalink
Remove Range header after Seek to origin
Browse files Browse the repository at this point in the history
  • Loading branch information
flobernd committed May 4, 2022
1 parent 0836bb8 commit 321e257
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api-get-object.go
Expand Up @@ -197,7 +197,7 @@ func (c *Client) GetObject(ctx context.Context, bucketName, objectName string, o
if req.isReadAt {
// Range is set with respect to the offset and length of the buffer requested.
opts.SetRange(req.Offset, req.Offset+int64(len(req.Buffer))-1)
} else if req.Offset > 0 { // Range is set with respect to the offset.
} else { // Range is set with respect to the offset.
opts.SetRange(req.Offset, 0)
}
httpReader, objectInfo, _, err = c.getObject(ctx, bucketName, objectName, opts)
Expand Down
4 changes: 4 additions & 0 deletions api-get-options.go
Expand Up @@ -113,6 +113,10 @@ func (o *GetObjectOptions) SetModified(modTime time.Time) error {
// See https://tools.ietf.org/html/rfc7233#section-3.1 for reference.
func (o *GetObjectOptions) SetRange(start, end int64) error {
switch {
case start == 0 && end == 0:
if o.headers != nil {
delete(o.headers, "Range")
}
case start == 0 && end < 0:
// Read last '-end' bytes. `bytes=-N`.
o.Set("Range", fmt.Sprintf("bytes=%d", end))
Expand Down

0 comments on commit 321e257

Please sign in to comment.