Skip to content

fix(FileResponse): guard 416 response behind range header presence check#1750

Closed
Copilot wants to merge 2 commits intot8from
copilot/sub-pr-1747-again
Closed

fix(FileResponse): guard 416 response behind range header presence check#1750
Copilot wants to merge 2 commits intot8from
copilot/sub-pr-1747-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

FileResponse was returning 416 Range Not Satisfiable for requests that included no Range header at all — most notably, any request for a 0-byte file, since startFrom defaults to 0 and 0 >= f.length() is true for empty files.

Change

  • FileResponse.java line 239: Added range != null && to the satisfiability guard so a 416 is only emitted when the client actually sent a Range header with an out-of-bounds value.
// Before — fires on empty files even without a Range header
if (startFrom < 0 || startFrom >= f.length()) { ... }

// After — only fires when Range was requested and is invalid
if (range != null && (startFrom < 0 || startFrom >= f.length())) { ... }

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI mentioned this pull request Mar 9, 2026
Merged
Co-authored-by: nmaguiar <11761746+nmaguiar@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback from PR #1747 for T8 changes fix(FileResponse): guard 416 response behind range header presence check Mar 9, 2026
@nmaguiar nmaguiar closed this Mar 9, 2026
@nmaguiar nmaguiar deleted the copilot/sub-pr-1747-again branch March 9, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants