Merge pull request #4364 from mendhak/proxy

Allow dotnet-install.ps1 to work behind an outbound proxy
This commit is contained in:
Livar 2016-10-10 17:15:52 -07:00 committed by GitHub
commit 40c7144fc2

View file

@ -47,6 +47,8 @@
.PARAMETER AzureFeed
Default: https://dotnetcli.azureedge.net/dotnet
This parameter should not be usually changed by user. It allows to change URL for the Azure feed used by this installer.
.PARAMETER ProxyAddress
If set, the installer will use the proxy when making web requests
#>
[cmdletbinding()]
param(
@ -59,7 +61,8 @@ param(
[switch]$DryRun,
[switch]$NoPath,
[string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet",
[string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet"
[string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet",
[string]$ProxyAddress
)
Set-StrictMode -Version Latest
@ -133,7 +136,15 @@ 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
$HttpClient = New-Object System.Net.Http.HttpClient
if($ProxyAddress){
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
$HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress}
$HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler
}
else {
$HttpClient = New-Object System.Net.Http.HttpClient
}
$Response = $HttpClient.GetAsync($Uri).Result
if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode)))
{