Skip to content

Commit 05005ca

Browse files
authored
fix: Warn about using streaming responses with a body (#4033)
1 parent e7477ac commit 05005ca

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

litestar/response/streaming.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(
5454
Args:
5555
background: A background task or a list of background tasks to be executed after the response is sent.
5656
body: encoded content to send in the response body.
57+
.. deprecated:: 2.16
5758
content_length: The response content length.
5859
cookies: The response cookies.
5960
encoded_headers: The response headers.
@@ -64,6 +65,16 @@ def __init__(
6465
media_type: The response media type.
6566
status_code: The response status code.
6667
"""
68+
69+
if body:
70+
warn_deprecation(
71+
version="2.16",
72+
kind="parameter",
73+
deprecated_name="body",
74+
removal_in="3.0",
75+
info="'body' passed to a streaming response will be ignored. Streams should always be iterables",
76+
)
77+
6778
super().__init__(
6879
background=background,
6980
body=body,
@@ -226,7 +237,6 @@ def to_asgi_response(
226237

227238
return ASGIStreamingResponse(
228239
background=self.background or background,
229-
body=b"",
230240
content_length=0,
231241
cookies=cookies,
232242
encoded_headers=encoded_headers,

0 commit comments

Comments
 (0)