Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 497d048

Browse files
committed
Support corporate proxy servers
1 parent 3037fdd commit 497d048

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scripts/obtain/dotnet-install.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,17 @@ function GetHTTPResponse([Uri] $Uri)
140140
try {
141141
# HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet.
142142
Load-Assembly -Assembly System.Net.Http
143+
144+
if(-not $ProxyAddress)
145+
{
146+
# Despite no proxy being explicitly specified, we may still be behind a default proxy
147+
$DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy;
148+
if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){
149+
$ProxyAddress = $DefaultProxy.GetProxy($Uri).OriginalString
150+
$ProxyUseDefaultCredentials = $true
151+
}
152+
}
153+
143154
if($ProxyAddress){
144155
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
145156
$HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress;UseDefaultCredentials=$ProxyUseDefaultCredentials}

0 commit comments

Comments
 (0)