Skip to content

Commit

Permalink
[PR #10058/12372d7 backport][3.11] Remove unreachable content length …
Browse files Browse the repository at this point in the history
…check for chunked encoding (#10060)
  • Loading branch information
bdraco authored Nov 27, 2024
1 parent 7e628f4 commit a5a6981
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 a5a6981

Please sign in to comment.