A Manual Download Omits the Last Byte of a Requested Range
Level 2 · node · API · Inclusive end-offset error in HTTP byte ranges
Scenario
A fictional equipment-manual download service returns selected byte ranges from a stored file. Both the starting and ending offsets are inclusive. Full downloads work, but partial downloads omit the explicitly requested final byte. Trace the file store, range reader, and controller to restore the byte-level contract.
Requirements
Without a Range header, return the full file with status 200. For bytes=start-end, include both boundary bytes and return status 206 with the correct contentRange. For bytes=start-, read through the file's end. Reject starts beyond the file and reversed ranges with RangeError. Preserve the existing signatures and Buffer return type.
Acceptance criteria
- Without a Range header, return the entire file.
- A single-byte range returns exactly one byte.
- An open-ended range returns through the final byte.
- Include the byte at the explicit ending offset.
- A range ending at the file's final byte is valid.
- Reject a range starting at or beyond the file size with RangeError.