Skip to content

Commit

Permalink
fix: readRemote range request input (#136)
Browse files Browse the repository at this point in the history
* fix readRemote

* use 0 isntead of -1

* remove bad line

* fix gen

* only set range when needed

---------

Co-authored-by: Łukasz Magiera <magik6k@gmail.com>
  • Loading branch information
LexLuthr and magik6k authored Aug 9, 2024
1 parent 0790da9 commit 65e1e60
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/paths/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,15 @@ func (r *Remote) readRemote(ctx context.Context, url string, offset, size abi.Pa
if r.auth != nil {
req.Header = r.auth.Clone()
}
req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", offset, offset+size-1))

if offset != 0 || size != 0 {
req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", offset, offset+size-1))

if size == 0 {
req.Header.Set("Range", fmt.Sprintf("bytes=%d-", offset))
}
}

req = req.WithContext(ctx)

resp, err := http.DefaultClient.Do(req)
Expand Down

0 comments on commit 65e1e60

Please sign in to comment.