mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-25 04:51:07 +07:00
feat: use ProxyAddress with Credential when passed to powershell script
In a proxy environment, such as in an enterprise, HTTP(S)_PROXY often takes the form of credentials, i.e., http://user:pass@host:port. When $ProxyAddress is passed in this format, WebProxy does not use the authentication information by default. This PR aims to solve the above problem.
This commit is contained in:
parent
5d1464d5da
commit
d10d64864f
7
externals/install-dotnet.ps1
vendored
7
externals/install-dotnet.ps1
vendored
@ -416,6 +416,13 @@ function GetHTTPResponse([Uri] $Uri, [bool]$HeaderOnly, [bool]$DisableRedirect,
|
||||
UseDefaultCredentials=$ProxyUseDefaultCredentials;
|
||||
BypassList = $ProxyBypassList;
|
||||
}
|
||||
# If ProxyAddress is contained username and password, then set credentials
|
||||
# e.g. http://(user):(pass)@...
|
||||
if ($ProxyAddress -match '://(.*?):(.*?)@') {
|
||||
$proxyUsername = $matches[1]
|
||||
$proxyPassword = $matches[2]
|
||||
$HttpClientHandler.Proxy.Credentials = New-Object System.Net.NetworkCredential($proxyUsername, $proxyPassword)
|
||||
}
|
||||
}
|
||||
if ($DisableRedirect)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user