Using HttpClientHandler only if ProxyAddress argument specified
This commit is contained in:
parent
047eb4f732
commit
ee239e54cf
1 changed files with 5 additions and 2 deletions
7
scripts/obtain/dotnet-install.ps1
vendored
7
scripts/obtain/dotnet-install.ps1
vendored
|
@ -136,12 +136,15 @@ function GetHTTPResponse([Uri] $Uri)
|
||||||
try {
|
try {
|
||||||
# HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet.
|
# 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
|
Load-Assembly -Assembly System.Net.Http
|
||||||
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
|
|
||||||
if($ProxyAddress){
|
if($ProxyAddress){
|
||||||
|
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
|
||||||
$HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress}
|
$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
|
||||||
}
|
}
|
||||||
|
|
||||||
$HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler
|
|
||||||
$Response = $HttpClient.GetAsync($Uri).Result
|
$Response = $HttpClient.GetAsync($Uri).Result
|
||||||
if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode)))
|
if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode)))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue