Skip to content

Commit

Permalink
Fix downloading behind proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
sworisbreathing committed Sep 2, 2019
1 parent 82a509a commit 3d8186e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pyenv-win/libexec/pyenv-install.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,26 @@ listEnv = Array(_
Function DownloadFile(strUrl,strFile)
Dim objHttp
Dim httpProxy
Set objHttp = WScript.CreateObject("Msxml2.ServerXMLHTTP")
Dim proxyArr
Set objHttp = WScript.CreateObject("WinHttp.WinHttpRequest.5.1")
on error resume next
httpProxy = objws.ExpandEnvironmentStrings("%http_proxy%")
if httpProxy <> "" AND httpProxy <> "%http_proxy%" Then
if InStr(1, httpProxy, "@") > 0 then
' The http_proxy environment variable is set with basic authentication
' WinHttp seems to work fine without the credentials, so we should be
' okay with just the hostname/port part
proxyArr = Split(httpProxy, "@")
objHttp.setProxy 2, proxyArr(1)
else
objHttp.setProxy 2, httpProxy
end if
end if
Call objHttp.Open("GET", strUrl, False )
if Err.Number <> 0 then
WScript.Echo Err.Description
WScript.Quit
end if
httpProxy = objws.ExpandEnvironmentStrings("%http_proxy%")
if httpProxy <> "" AND httpProxy <> "%http_proxy%" Then
objHttp.setProxy 2, httpProxy
end if
objHttp.Send

if Err.Number <> 0 then
Expand Down

0 comments on commit 3d8186e

Please sign in to comment.