Fix Content-Length mismatch on range requests (206 Partial Content)

This commit is contained in:
2026-02-06 16:14:35 +08:00
parent 77a46d0725
commit 54705ab9c4
2 changed files with 3 additions and 2 deletions

View File

@@ -999,7 +999,8 @@ def _apply_object_headers(
etag: str,
) -> None:
if file_stat is not None:
response.headers["Content-Length"] = str(file_stat.st_size)
if response.status_code != 206:
response.headers["Content-Length"] = str(file_stat.st_size)
response.headers["Last-Modified"] = http_date(file_stat.st_mtime)
response.headers["ETag"] = f'"{etag}"'
response.headers["Accept-Ranges"] = "bytes"