From 04733438daa9ce274b3dd1d1cad66b51b43ef6e1 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Tue, 3 Oct 2023 16:12:53 -0700 Subject: [PATCH] check head request response --- server/download.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/download.go b/server/download.go index 7acc09d5..f5ebd8f8 100644 --- a/server/download.go +++ b/server/download.go @@ -78,6 +78,11 @@ func (b *blobDownload) Prepare(ctx context.Context, requestURL *url.URL, opts *R } defer resp.Body.Close() + if resp.StatusCode >= http.StatusBadRequest { + body, _ := io.ReadAll(resp.Body) + return fmt.Errorf("registry responded with code %d: %v", resp.StatusCode, string(body)) + } + b.Total, _ = strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64) var offset int64