Merge pull request #6563 from jlanng/corporate-proxy-support
Support corporate proxy servers
This commit is contained in:
commit
d6452010c4
1 changed files with 11 additions and 0 deletions
11
scripts/obtain/dotnet-install.ps1
vendored
11
scripts/obtain/dotnet-install.ps1
vendored
|
@ -140,6 +140,17 @@ function GetHTTPResponse([Uri] $Uri)
|
|||
try {
|
||||
# HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet.
|
||||
Load-Assembly -Assembly System.Net.Http
|
||||
|
||||
if(-not $ProxyAddress)
|
||||
{
|
||||
# Despite no proxy being explicitly specified, we may still be behind a default proxy
|
||||
$DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy;
|
||||
if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){
|
||||
$ProxyAddress = $DefaultProxy.GetProxy($Uri).OriginalString
|
||||
$ProxyUseDefaultCredentials = $true
|
||||
}
|
||||
}
|
||||
|
||||
if($ProxyAddress){
|
||||
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
|
||||
$HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress;UseDefaultCredentials=$ProxyUseDefaultCredentials}
|
||||
|
|
Loading…
Reference in a new issue