Browse code

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>

Jacob Wen authored on 2017/07/14 16:25:27
Showing 1 changed files
... ...
@@ -64,7 +64,7 @@ fetch_blob() {
64 64
 			-D-
65 65
 	)"
66 66
 	curlHeaders="$(echo "$curlHeaders" | tr -d '\r')"
67
-	if [ "$(echo "$curlHeaders" | awk 'NR == 1 { print $2; exit }')" != '200' ]; then
67
+	if echo "$curlHeaders" | grep -qE "^HTTP/[0-9].[0-9] 3"; then
68 68
 		rm -f "$targetFile"
69 69
 
70 70
 		local blobRedirect="$(echo "$curlHeaders" | awk -F ': ' 'tolower($1) == "location" { print $2; exit }')"