diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py index 1ea6a56db46..6ee70786cfb 100644 --- a/aiohttp/helpers.py +++ b/aiohttp/helpers.py @@ -814,11 +814,7 @@ def charset(self) -> Optional[str]: def content_length(self) -> Optional[int]: """The value of Content-Length HTTP header.""" content_length = self._headers.get(hdrs.CONTENT_LENGTH) - - if content_length is not None: - return int(content_length) - else: - return None + return None if content_length is None else int(content_length) def set_result(fut: "asyncio.Future[_T]", result: _T) -> None: diff --git a/aiohttp/web_response.py b/aiohttp/web_response.py index 4d5095a4fea..2036a8d088b 100644 --- a/aiohttp/web_response.py +++ b/aiohttp/web_response.py @@ -709,7 +709,7 @@ def content_length(self) -> Optional[int]: return None if hdrs.CONTENT_LENGTH in self._headers: - return super().content_length + return int(self._headers[hdrs.CONTENT_LENGTH]) if self._compressed_body is not None: # Return length of the compressed body