diff --git a/main.go b/main.go index b9da6b3..36f3ecc 100644 --- a/main.go +++ b/main.go @@ -33,18 +33,8 @@ var config Config var client = &http.Client{ CheckRedirect: func(req *http.Request, via []*http.Request) error { - for key, val := range via[0].Header { - if _, ok := req.Header[key]; !ok { - req.Header[key] = val - } - } - - // S3 重定向时添加必要的头 - if strings.Contains(req.URL.Host, "amazonaws.com") { - req.Header.Set("x-amz-content-sha256", "UNSIGNED-PAYLOAD") - } - - return nil + // 不跟随重定向,让 Docker 客户端自己处理 + return http.ErrUseLastResponse }, Timeout: 30 * time.Second, Transport: &http.Transport{ @@ -516,9 +506,6 @@ func sendRequestWithContext(ctx context.Context, method, url string, headers htt req.Header = headers - // 为可能的 S3 重定向预先添加头 - req.Header.Set("x-amz-content-sha256", "UNSIGNED-PAYLOAD") - startTime := time.Now() resp, err := client.Do(req)