Skip to content

Commit

Permalink
Improve performance of _serialize_headers (#9603)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Nov 2, 2024
1 parent 898aa28 commit 4108ca5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/9603.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved performance of serializing HTTP headers -- by :user:`bdraco`.
7 changes: 3 additions & 4 deletions aiohttp/_http_writer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ def _serialize_headers(str status_line, headers):

_init_writer(&writer)

for key, val in headers.items():
_safe_header(to_str(key))
_safe_header(to_str(val))

try:
if _write_str(&writer, status_line) < 0:
raise
Expand All @@ -140,6 +136,9 @@ def _serialize_headers(str status_line, headers):
raise

for key, val in headers.items():
_safe_header(to_str(key))
_safe_header(to_str(val))

if _write_str(&writer, to_str(key)) < 0:
raise
if _write_byte(&writer, b':') < 0:
Expand Down

0 comments on commit 4108ca5

Please sign in to comment.