-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #128 using internal boxstarter function for downloading http re…
…sources
- Loading branch information
Showing
15 changed files
with
80 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
function Get-HttpResource { | ||
<# | ||
.SYNOPSIS | ||
Downloads the contents from a URL | ||
.DESCRIPTION | ||
Get-HttpResource downloads the contents of an HTTP url. | ||
When -PassThru is specified it returns the string content. | ||
.PARAMETER Url | ||
The url containing the content to download. | ||
.PARAMETER OutputPath | ||
If provided, the content will be saved to this path. | ||
.PARAMETER PassThru | ||
If provided, the string will be output to the pipeline. | ||
.EXAMPLE | ||
$content = Get-HttpResource -Url 'http://my/url' ` | ||
-OutputPath 'c:\myfile.txt' ` | ||
-PassThru | ||
This downloads the content located at http://my/url and | ||
saves it to a file at c:\myfile.txt and also returns | ||
the downloaded string. | ||
.LINK | ||
http://boxstarter.org | ||
#> | ||
param ( | ||
[string]$Url, | ||
[string]$OutputPath = $null, | ||
[switch]$PassThru | ||
) | ||
Write-BoxstarterMessage "Downloading $url" -Verbose | ||
$str = Invoke-RetriableScript -RetryScript { | ||
$downloader=new-object net.webclient | ||
$wp=[system.net.WebProxy]::GetDefaultProxy() | ||
$wp.UseDefaultCredentials=$true | ||
$downloader.Proxy=$wp | ||
try { | ||
$httpString = $downloader.DownloadString($args[0]) | ||
if($args[1]) { | ||
Write-BoxstarterMessage "Saving $httpString to $($args[1])" -Verbose | ||
if(Test-Path $args[1]){Remove-Item $args[1] -Force} | ||
$httpString | Out-File -FilePath $args[1] -Encoding utf8 | ||
} | ||
$httpString | ||
} | ||
catch{ | ||
if($VerbosePreference -eq "Continue"){ | ||
Write-Error $($_.Exception | fl * -Force | Out-String) | ||
} | ||
throw $_ | ||
} | ||
} $Url $OutputPath | ||
|
||
if($PassThru) { Write-Output $str } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<releaseNotes> | ||
- Use internal function to download http gist scripts. | ||
- No longer vendors a legacy version of Chocolatey. Leverages the current beta Chocolatey library API for all Chocolatey interaction. | ||
</releaseNotes> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters