From 65e1e6049f19bcbbfd449470bd7773a41c17657f Mon Sep 17 00:00:00 2001 From: LexLuthr <88259624+LexLuthr@users.noreply.github.com> Date: Fri, 9 Aug 2024 12:33:30 +0400 Subject: [PATCH] fix: readRemote range request input (#136) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix readRemote * use 0 isntead of -1 * remove bad line * fix gen * only set range when needed --------- Co-authored-by: Ɓukasz Magiera --- lib/paths/remote.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/paths/remote.go b/lib/paths/remote.go index 217a24e3d..ed696bf76 100644 --- a/lib/paths/remote.go +++ b/lib/paths/remote.go @@ -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)