mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
download-frozen-image-v2: Use curl -L
Passing the Auth to the redirected location was fixed in curl 7.58: https://curl.se/changes.html#7_58_0 so we no longer need the extra handling and can just use `-L` to let curl handle redirects. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -72,30 +72,11 @@ fetch_blob() {
|
|||||||
shift
|
shift
|
||||||
local curlArgs=("$@")
|
local curlArgs=("$@")
|
||||||
|
|
||||||
local curlHeaders
|
curl -L -S "${curlArgs[@]}" \
|
||||||
curlHeaders="$(
|
-H "Authorization: Bearer $token" \
|
||||||
curl -S "${curlArgs[@]}" \
|
"$registryBase/v2/$image/blobs/$digest" \
|
||||||
-H "Authorization: Bearer $token" \
|
-o "$targetFile" \
|
||||||
"$registryBase/v2/$image/blobs/$digest" \
|
-D-
|
||||||
-o "$targetFile" \
|
|
||||||
-D-
|
|
||||||
)"
|
|
||||||
curlHeaders="$(echo "$curlHeaders" | tr -d '\r')"
|
|
||||||
if grep -qE "^HTTP/[0-9](.[0-9])* 3" <<< "$curlHeaders"; then
|
|
||||||
rm -f "$targetFile"
|
|
||||||
|
|
||||||
local blobRedirect
|
|
||||||
blobRedirect="$(echo "$curlHeaders" | awk -F ': ' 'tolower($1) == "location" { print $2; exit }')"
|
|
||||||
if [ -z "$blobRedirect" ]; then
|
|
||||||
echo >&2 "error: failed fetching '$image' blob '$digest'"
|
|
||||||
echo "$curlHeaders" | head -1 >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
curl -fSL "${curlArgs[@]}" \
|
|
||||||
"$blobRedirect" \
|
|
||||||
-o "$targetFile"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# handle 'application/vnd.docker.distribution.manifest.v2+json' manifest
|
# handle 'application/vnd.docker.distribution.manifest.v2+json' manifest
|
||||||
|
|||||||
Reference in New Issue
Block a user