diff --git a/aiohttp/web_response.py b/aiohttp/web_response.py index e05799ca7b7..cd2be24f1a3 100644 --- a/aiohttp/web_response.py +++ b/aiohttp/web_response.py @@ -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, @@ -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: