Reject inverted single-byte Range like bytes=5-4

Merged
NI
3mo ago
+14-1

Summary

Closes #3388.

FileResponse._parse_range_header only rejected ranges where start > end, but bytes=5-4 parses to the empty half-open range (5, 5) and slipped past that guard, producing a malformed 206 (Content-Length: 0, a backwards Content-Range) instead of a 400. bytes=10-5 was already caught (it parses to (10, 6)); the missed case is the off-by-one boundary where end + 1 == start.

The guard is now start >= end. A genuine one-byte request bytes=5-5 parses to (5, 6) and is unaffected.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.