Skip to content

Commit

Permalink
Cope with zero-length http downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
mkke authored and randombenj committed Jun 20, 2022
1 parent a687df2 commit 4b2efee
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions http/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ func (downloader *downloaderImpl) GetLength(ctx context.Context, url string) (in
}

if resp.ContentLength < 0 {
// an existing, but zero-length file can be reported with ContentLength -1
if resp.StatusCode == 200 && resp.ContentLength == -1 {
return 0, nil
}
return -1, fmt.Errorf("could not determine length of %s", url)
}

Expand Down

0 comments on commit 4b2efee

Please sign in to comment.