From 0d339103b64632990ba8f0b6b1ea6d8a9b85a729 Mon Sep 17 00:00:00 2001 From: sus <54392299+jeffpeng3@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:04:47 +0000 Subject: [PATCH] fix: content_range should not be reduced by one. --- CHANGES.rst | 2 ++ src/quart/wrappers/response.py | 2 +- tests/wrappers/test_response.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index dbede375..c8ffef1f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,5 @@ +* Fixed Issue #331. Use ContentRange in the right way. + 0.19.5 2024-04-01 ----------------- diff --git a/src/quart/wrappers/response.py b/src/quart/wrappers/response.py index 9460c2ec..2fe27c2f 100644 --- a/src/quart/wrappers/response.py +++ b/src/quart/wrappers/response.py @@ -414,7 +414,7 @@ async def _process_range_request( self.content_range = ContentRange( request_range.units, self.response.begin, # type: ignore - self.response.end - 1, # type: ignore + self.response.end, # type: ignore complete_length, ) self.status_code = 206 diff --git a/tests/wrappers/test_response.py b/tests/wrappers/test_response.py index 3a7d1485..99a77a32 100644 --- a/tests/wrappers/test_response.py +++ b/tests/wrappers/test_response.py @@ -97,7 +97,7 @@ async def test_response_make_conditional(http_scope: HTTPScope) -> None: assert response.accept_ranges == "bytes" assert response.content_range.units == "bytes" assert response.content_range.start == 0 - assert response.content_range.stop == 3 + assert response.content_range.stop == 4 assert response.content_range.length == 6