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 <jian.w.wen@oracle.com>
This commit is contained in:
Jacob Wen 2017-07-14 15:25:27 +08:00
parent 1daa10301a
commit 238d17c456
1 changed files with 1 additions and 1 deletions

View File

@ -64,7 +64,7 @@ fetch_blob() {
-D- -D-
)" )"
curlHeaders="$(echo "$curlHeaders" | tr -d '\r')" 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" rm -f "$targetFile"
local blobRedirect="$(echo "$curlHeaders" | awk -F ': ' 'tolower($1) == "location" { print $2; exit }')" local blobRedirect="$(echo "$curlHeaders" | awk -F ': ' 'tolower($1) == "location" { print $2; exit }')"