]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Version 0.39.0 (#2699) 0.39.0
authorMarcelo Trylesinski <marcelotryle@gmail.com>
Mon, 23 Sep 2024 06:13:56 +0000 (08:13 +0200)
committerGitHub <noreply@github.com>
Mon, 23 Sep 2024 06:13:56 +0000 (08:13 +0200)
docs/release-notes.md
docs/responses.md
starlette/__init__.py
starlette/responses.py

index cd71697d2af87b3f61b9ed13eb1debec9649925b..f7c73797434290e6216c613f77101c6b3f5b0ce5 100644 (file)
@@ -3,6 +3,13 @@ hide: navigation
 toc_depth: 2
 ---
 
+## 0.39.0 (September 23, 2024)
+
+#### Added
+
+* Add support for [HTTP Range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests) to
+  `FileResponse` [#2697](https://github.com/encode/starlette/pull/2697).
+
 ## 0.38.6 (September 22, 2024)
 
 #### Fixed
index ae48d2f14a496bea25ecebde91b58caba5d30706..a19f7701864bf7aeaa23da090998f901cbecb5ec 100644 (file)
@@ -183,12 +183,16 @@ async def app(scope, receive, send):
     await response(scope, receive, send)
 ```
 
+File responses also supports [HTTP range requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests).
+
+The `Accept-Ranges: bytes` header will be included in the response if the file exists. For now, only the `bytes`
+range unit is supported.
+
+If the request includes a `Range` header, and the file exists, the response will be a `206 Partial Content` response
+with the requested range of bytes. If the range is invalid, the response will be a `416 Range Not Satisfiable` response.
+
 ## Third party responses
 
 #### [EventSourceResponse](https://github.com/sysid/sse-starlette)
 
 A response class that implements [Server-Sent Events](https://html.spec.whatwg.org/multipage/server-sent-events.html). It enables event streaming from the server to the client without the complexity of websockets.
-
-#### [baize.asgi.FileResponse](https://baize.aber.sh/asgi#fileresponse)
-
-As a smooth replacement for Starlette [`FileResponse`](https://www.starlette.io/responses/#fileresponse), it will automatically handle [Head method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) and [Range requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests).
index f2664a769726c886e1a4f6721cff4611f38e4fab..e72781a79a8d572e8fe079d59fb7fbb112b8793b 100644 (file)
@@ -1 +1 @@
-__version__ = "0.38.6"
+__version__ = "0.39.0"
index cf8d6e6b4971062ba4ec1e38a40f5b2d0713ea0e..b73e04a40765692ac693a66b542e199ec93d1f8e 100644 (file)
@@ -12,7 +12,6 @@ from email.utils import format_datetime, formatdate
 from functools import partial
 from mimetypes import guess_type
 from random import choices as random_choices
-from typing import Mapping
 from urllib.parse import quote
 
 import anyio
@@ -280,7 +279,7 @@ class FileResponse(Response):
         self,
         path: str | os.PathLike[str],
         status_code: int = 200,
-        headers: Mapping[str, str] | None = None,
+        headers: typing.Mapping[str, str] | None = None,
         media_type: str | None = None,
         background: BackgroundTask | None = None,
         filename: str | None = None,