Skip to content

Commit e7c859f

Browse files
committed
Improve Get-File
Add UseBasicParsing to support pwsh 5.1
1 parent 6a971f3 commit e7c859f

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

extension/BuildPhpExtension/private/Get-File.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@ Function Get-File {
3535
for ($i = 0; $i -lt $Retries; $i++) {
3636
try {
3737
if($OutFile -ne '') {
38-
Invoke-WebRequest -Uri $Url -OutFile $OutFile -TimeoutSec $TimeoutSec
38+
Invoke-WebRequest -Uri $Url -OutFile $OutFile -TimeoutSec $TimeoutSec -UseBasicParsing
3939
} else {
40-
Invoke-WebRequest -Uri $Url -TimeoutSec $TimeoutSec
40+
Invoke-WebRequest -Uri $Url -TimeoutSec $TimeoutSec -UseBasicParsing
4141
}
4242
break;
4343
} catch {
4444
if ($i -eq ($Retries - 1)) {
4545
if($FallbackUrl) {
4646
try {
4747
if($OutFile -ne '') {
48-
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec
48+
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec -UseBasicParsing
4949
} else {
50-
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec
50+
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec -UseBasicParsing
5151
}
5252
} catch {
53-
throw "Failed to download the file from $Url and $FallbackUrl"
53+
throw "Failed to download the file from $Url and $FallbackUrl - $($_.Exception.Message)"
5454
}
5555
} else {
56-
throw "Failed to download the file from $Url"
56+
throw "Failed to download the file from $Url - $($_.Exception.Message)"
5757
}
5858
}
5959
}

php/BuildPhp/private/Get-File.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@ Function Get-File {
3535
for ($i = 0; $i -lt $Retries; $i++) {
3636
try {
3737
if($OutFile -ne '') {
38-
Invoke-WebRequest -Uri $Url -OutFile $OutFile -TimeoutSec $TimeoutSec
38+
Invoke-WebRequest -Uri $Url -OutFile $OutFile -TimeoutSec $TimeoutSec -UseBasicParsing
3939
} else {
40-
Invoke-WebRequest -Uri $Url -TimeoutSec $TimeoutSec
40+
Invoke-WebRequest -Uri $Url -TimeoutSec $TimeoutSec -UseBasicParsing
4141
}
4242
break;
4343
} catch {
4444
if ($i -eq ($Retries - 1)) {
4545
if($FallbackUrl) {
4646
try {
4747
if($OutFile -ne '') {
48-
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec
48+
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec -UseBasicParsing
4949
} else {
50-
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec
50+
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec -UseBasicParsing
5151
}
5252
} catch {
53-
throw "Failed to download the file from $Url and $FallbackUrl"
53+
throw "Failed to download the file from $Url and $FallbackUrl - $($_.Exception.Message)"
5454
}
5555
} else {
56-
throw "Failed to download the file from $Url"
56+
throw "Failed to download the file from $Url - $($_.Exception.Message)"
5757
}
5858
}
5959
}

0 commit comments

Comments
 (0)