From 55398edf4d74ec388a21a30c8d9a00f5cd834e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20St=C3=BCrmer?= Date: Tue, 14 Jun 2022 14:04:08 +0200 Subject: [PATCH] Cope with zero-length http downloads --- http/download.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/http/download.go b/http/download.go index 24be26ffe..3c2a1ebd8 100644 --- a/http/download.go +++ b/http/download.go @@ -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) }