Skip to content

Commit 40981ce

Browse files
authored
feat!: Remove deprecated body param from streaming and file responses (#4034)
remove 'body' param from streaming and file responses
1 parent bac2927 commit 40981ce

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

docs/release-notes/whats-new-3.rst

+9
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,12 @@ of the abstract :class:`~litestar.plugins.SerializationPlugin`. The functionalit
272272
interface remain the same, the only difference being that plugins that wish to provide
273273
this functionality are now required to inherit from
274274
:class:`~.plugins.SerializationPlugin`.
275+
276+
277+
Removal of ``body`` in streaming responses
278+
-------------------------------------------
279+
280+
The unsupported ``body`` parameter of :class:`~.ASGIStreamingResponse`
281+
and :class:`.ASGIFileResponse` has been removed.
282+
283+
This does not change any behaviour, as this parameter was previously ignored.

litestar/response/file.py

-5
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def __init__(
124124
self,
125125
*,
126126
background: BackgroundTask | BackgroundTasks | None = None,
127-
body: bytes | str = b"",
128127
chunk_size: int = ONE_MEGABYTE,
129128
content_disposition_type: Literal["attachment", "inline"] = "attachment",
130129
content_length: int | None = None,
@@ -146,7 +145,6 @@ def __init__(
146145
147146
Args:
148147
background: A background task or a list of background tasks to be executed after the response is sent.
149-
body: encoded content to send in the response body.
150148
chunk_size: The chunk size to use.
151149
content_disposition_type: The type of the ``Content-Disposition``. Either ``inline`` or ``attachment``.
152150
content_length: The response content length.
@@ -181,7 +179,6 @@ def __init__(
181179
cookies=cookies,
182180
background=background,
183181
status_code=status_code,
184-
body=body,
185182
content_length=content_length,
186183
encoding=encoding,
187184
is_head_response=is_head_response,
@@ -370,7 +367,6 @@ def to_asgi_response(
370367
"""Create an :class:`ASGIFileResponse <litestar.response.file.ASGIFileResponse>` instance.
371368
372369
Args:
373-
app: The :class:`Litestar <.app.Litestar>` application instance.
374370
background: Background task(s) to be executed after the response is sent.
375371
cookies: A list of cookies to be set on the response.
376372
encoded_headers: A list of already encoded headers.
@@ -394,7 +390,6 @@ def to_asgi_response(
394390

395391
return ASGIFileResponse(
396392
background=self.background or background,
397-
body=b"",
398393
chunk_size=self.chunk_size,
399394
content_disposition_type=self.content_disposition_type, # pyright: ignore
400395
content_length=0,

litestar/response/streaming.py

-13
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def __init__(
3838
*,
3939
iterator: StreamType,
4040
background: BackgroundTask | BackgroundTasks | None = None,
41-
body: bytes | str = b"",
4241
content_length: int | None = None,
4342
cookies: Iterable[Cookie] | None = None,
4443
encoded_headers: Iterable[tuple[bytes, bytes]] | None = None,
@@ -52,8 +51,6 @@ def __init__(
5251
5352
Args:
5453
background: A background task or a list of background tasks to be executed after the response is sent.
55-
body: encoded content to send in the response body.
56-
.. deprecated:: 2.16
5754
content_length: The response content length.
5855
cookies: The response cookies.
5956
encoded_headers: The response headers.
@@ -65,18 +62,8 @@ def __init__(
6562
status_code: The response status code.
6663
"""
6764

68-
if body:
69-
warn_deprecation(
70-
version="2.16",
71-
kind="parameter",
72-
deprecated_name="body",
73-
removal_in="3.0",
74-
info="'body' passed to a streaming response will be ignored. Streams should always be iterables",
75-
)
76-
7765
super().__init__(
7866
background=background,
79-
body=body,
8067
content_length=content_length,
8168
cookies=cookies,
8269
encoding=encoding,

0 commit comments

Comments
 (0)