Explorar el Código

check head request response

Michael Yang hace 1 año
padre
commit
04733438da
Se han modificado 1 ficheros con 5 adiciones y 0 borrados
  1. 5 0
      server/download.go

+ 5 - 0
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