Handle resume responses without Content-Range by KirtiRamchandani · Pull Request #27529 · PowerShell/PowerShell
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates PowerShell web cmdlets’ -Resume handling to tolerate non-compliant 416 RequestedRangeNotSatisfiable responses that omit Content-Range, treating them as “already complete”, and adds test coverage for this behavior.
Changes:
- Add a WebListener endpoint that returns
416without aContent-Rangeheader when aRangerequest is made. - Refactor and harden resume-range handling in
WebRequestPSCmdletto avoid null dereferences and treat missingContent-Rangeas complete. - Add Pester tests for
Invoke-WebRequestandInvoke-RestMethodvalidating the new-Resumebehavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/tools/WebListener/Controllers/ResumeController.cs | Adds a new test endpoint to simulate 416 without Content-Range for range requests |
| test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 | Adds regression tests for -Resume behavior when Content-Range is missing |
| src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs | Refactors resume logic into helpers and treats missing Content-Range as “already complete” |