Skip to content

Commit

Permalink
(chocolatey-archiveGH-577) use default credentials if available.
Browse files Browse the repository at this point in the history
  • Loading branch information
ferventcoder committed Nov 2, 2014
1 parent e01297a commit 4243be7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/functions/Chocolatey-InstallAll.ps1
Expand Up @@ -12,6 +12,10 @@ param(

if ($source.StartsWith('http')) {
$webClient = New-Object System.Net.WebClient
$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials
if ($defaultCreds -ne $null) {
$webClient.Credentials = $defaultCreds
}

if (!$source.EndsWith('/')) { $source = $source + '/' }
$feedUrl = $source + 'Packages/'
Expand Down
9 changes: 9 additions & 0 deletions src/helpers/functions/Get-WebFile.ps1
Expand Up @@ -25,8 +25,17 @@ param(
Write-Debug "Running 'Get-WebFile' for $fileName with url:`'$url`', userAgent: `'$userAgent`' ";
#if ($url -eq '' return)
$req = [System.Net.HttpWebRequest]::Create($url);
$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials
if ($defaultCreds -ne $null) {
$req.Credentials = $defaultCreds
}

# check if a proxy is required
$webclient = new-object System.Net.WebClient
if ($defaultCreds -ne $null) {
$webClient.Credentials = $defaultCreds
}

if (!$webclient.Proxy.IsBypassed($url))
{
$creds = [net.CredentialCache]::DefaultCredentials
Expand Down
9 changes: 9 additions & 0 deletions src/helpers/functions/Get-WebHeaders.ps1
Expand Up @@ -7,9 +7,18 @@ param(
if ($url -eq '') { return }

$request = [System.Net.HttpWebRequest]::Create($url);
$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials
if ($defaultCreds -ne $null) {
$request.Credentials = $defaultCreds
}

#$request.Method = "HEAD"
# check if a proxy is required
$client = New-Object System.Net.WebClient
if ($defaultCreds -ne $null) {
$client.Credentials = $defaultCreds
}

if (!$client.Proxy.IsBypassed($url))
{
$creds = [Net.CredentialCache]::DefaultCredentials
Expand Down

0 comments on commit 4243be7

Please sign in to comment.