Skip to content

Commit

Permalink
Speed up preparing headers by avoiding populating cookies when there …
Browse files Browse the repository at this point in the history
…are no cookies (#9745)

Co-authored-by: Emmanuel Okedele <emmanuel@coefficient.ai>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
  • Loading branch information
4 people authored Nov 9, 2024
1 parent 751c3c4 commit 0d10447
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aiohttp/web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ async def _prepare_headers(self) -> None:
version = request.version

headers = self._headers
populate_with_cookies(headers, self.cookies)
if self._cookies:
populate_with_cookies(headers, self._cookies)

if self._compression:
await self._start_compression(request)
Expand Down Expand Up @@ -431,9 +432,8 @@ async def _prepare_headers(self) -> None:
if keep_alive:
if version == HttpVersion10:
headers[hdrs.CONNECTION] = "keep-alive"
else:
if version == HttpVersion11:
headers[hdrs.CONNECTION] = "close"
elif version == HttpVersion11:
headers[hdrs.CONNECTION] = "close"

async def _write_headers(self) -> None:
request = self._req
Expand Down

0 comments on commit 0d10447

Please sign in to comment.