From cfc631fd9c0db16d80275ec75979d9de87ae7bbd Mon Sep 17 00:00:00 2001 From: Jacob Wen Date: Fri, 14 Jul 2017 15:25:27 +0800 Subject: [PATCH] Handle https proxy's CONNECT response When using a https proxy, an extra HTTP 200 header will be generated. So we can't rely on detecting the first http header. $curlHeaders with https proxy: "HTTP/1.0 200 Connection established <-- the https proxy's response HTTP/1.1 307 Temporary Redirect ... " See https://stackoverflow.com/a/34537988/889429 Fixes #34131 Signed-off-by: Jacob Wen Upstream-commit: 238d17c456c3ff0b8937b33538f6a4b36f829410 Component: engine --- components/engine/contrib/download-frozen-image-v2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/engine/contrib/download-frozen-image-v2.sh b/components/engine/contrib/download-frozen-image-v2.sh index 232679019d..2dfe247b5a 100755 --- a/components/engine/contrib/download-frozen-image-v2.sh +++ b/components/engine/contrib/download-frozen-image-v2.sh @@ -64,7 +64,7 @@ fetch_blob() { -D- )" curlHeaders="$(echo "$curlHeaders" | tr -d '\r')" - if [ "$(echo "$curlHeaders" | awk 'NR == 1 { print $2; exit }')" != '200' ]; then + if echo "$curlHeaders" | grep -qE "^HTTP/[0-9].[0-9] 3"; then rm -f "$targetFile" local blobRedirect="$(echo "$curlHeaders" | awk -F ': ' 'tolower($1) == "location" { print $2; exit }')"