Skip to content

Commit

Permalink
[PR #10058/12372d7 backport][3.12] Remove unreachable content length …
Browse files Browse the repository at this point in the history
…check for chunked encoding (#10061)
  • Loading branch information
bdraco authored Nov 27, 2024
1 parent 4409466 commit d88c30c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions aiohttp/web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,13 @@ def output_length(self) -> int:

def enable_chunked_encoding(self, chunk_size: Optional[int] = None) -> None:
"""Enables automatic chunked transfer encoding."""
self._chunked = True

if hdrs.CONTENT_LENGTH in self._headers:
raise RuntimeError(
"You can't enable chunked encoding when a content length is set"
)
if chunk_size is not None:
warnings.warn("Chunk size is deprecated #1615", DeprecationWarning)
self._chunked = True

def enable_compression(
self,
Expand Down Expand Up @@ -493,8 +492,6 @@ async def _prepare_headers(self) -> None:
if not self._must_be_empty_body:
writer.enable_chunking()
headers[hdrs.TRANSFER_ENCODING] = "chunked"
if hdrs.CONTENT_LENGTH in headers:
del headers[hdrs.CONTENT_LENGTH]
elif self._length_check: # Disabled for WebSockets
writer.length = self.content_length
if writer.length is None:
Expand Down

0 comments on commit d88c30c

Please sign in to comment.