Skip to content

Commit a5a6981

Browse files
authored
[PR #10058/12372d7 backport][3.11] Remove unreachable content length check for chunked encoding (#10060)
1 parent 7e628f4 commit a5a6981

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

aiohttp/web_response.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,13 @@ def output_length(self) -> int:
181181

182182
def enable_chunked_encoding(self, chunk_size: Optional[int] = None) -> None:
183183
"""Enables automatic chunked transfer encoding."""
184-
self._chunked = True
185-
186184
if hdrs.CONTENT_LENGTH in self._headers:
187185
raise RuntimeError(
188186
"You can't enable chunked encoding when a content length is set"
189187
)
190188
if chunk_size is not None:
191189
warnings.warn("Chunk size is deprecated #1615", DeprecationWarning)
190+
self._chunked = True
192191

193192
def enable_compression(
194193
self,
@@ -493,8 +492,6 @@ async def _prepare_headers(self) -> None:
493492
if not self._must_be_empty_body:
494493
writer.enable_chunking()
495494
headers[hdrs.TRANSFER_ENCODING] = "chunked"
496-
if hdrs.CONTENT_LENGTH in headers:
497-
del headers[hdrs.CONTENT_LENGTH]
498495
elif self._length_check: # Disabled for WebSockets
499496
writer.length = self.content_length
500497
if writer.length is None:

0 commit comments

Comments
 (0)