From 281b0e22e5696b283add3940d880491256751503 Mon Sep 17 00:00:00 2001 From: Jeremy Maitin-Shepard Date: Sat, 23 Mar 2024 12:31:23 -0700 Subject: [PATCH] fix: send correct content-range header if requested byte range was truncated (#622) Previously, if the requested byte range was truncated, an invalid content-range header was sent. --- gcs/object.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcs/object.py b/gcs/object.py index 9e5cd547..de0ff152 100644 --- a/gcs/object.py +++ b/gcs/object.py @@ -369,6 +369,8 @@ def _download_range(self, request, response_payload): begin = int(m.group(1)) end = int(m.group(2)) + 1 response_payload = response_payload[begin:end] + # Ensure end is correct if the specified byte range was truncated. + end = begin + len(response_payload) m = re.match("bytes=([0-9]+)-$", range_header) if m: begin = int(m.group(1))