Skip to content

Commit

Permalink
(GH-746) Use HTTPS if available when HTTP url
Browse files Browse the repository at this point in the history
If the host can be addressed with HTTPS, switch the download url to use
HTTPS.
  • Loading branch information
ferventcoder committed Sep 12, 2016
1 parent 27d6e39 commit 66b636a
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ param(
throw "This package does not support $bitWidth bit architecture."
}

# determine if the url can be SSL/TLS
if ($url.StartsWith('http:')) {
try {
$httpsUrl = $url.Replace("http://", "https://")
Get-WebHeaders -Url $httpsUrl -ErrorAction "Stop" | Out-Null
$url = $httpsUrl
Write-Warning "Url has SSL/TLS available, switching to HTTPS for download"
} catch {
Write-Debug "Url does not have HTTPS available"
}
}

if ($getOriginalFileName) {
try {
$fileDirectory = [System.IO.Path]::GetDirectoryName($fileFullPath)
Expand Down

0 comments on commit 66b636a

Please sign in to comment.