Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Public/Functions/Other/Save-WebFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ function Save-WebFile {
Write-Verbose "Destination: $DestinationFullName"

Write-Verbose 'Requesing HTTP HEAD to get Content-Length and Accept-Ranges header'
$remote = Invoke-WebRequest -UseBasicParsing -Method Head -Uri $SourceUrl
try {
$remote = Invoke-WebRequest -UseBasicParsing -Method Head -Uri $SourceUrl
}
catch {
Write-Warning "$_" # Error Example: Response status code does not indicate success: 404 (Not Found).
Return $null
}
$remoteLength = [Int64]($remote.Headers.'Content-Length' | Select-Object -First 1)
$remoteAcceptsRanges = ($remote.Headers.'Accept-Ranges' | Select-Object -First 1) -eq 'bytes'

Expand Down