Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES/12321.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added ``cdef`` type declarations and inlined the upgrade check in the HTTP parser
-- by :user:`bdraco`.
6 changes: 4 additions & 2 deletions aiohttp/_http_parser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ cdef class HttpParser:
self._has_value = True

cdef _on_headers_complete(self):
cdef str h_upg
cdef str enc

self._process_header()

should_close = not cparser.llhttp_should_keep_alive(self._cparser)
Expand All @@ -457,8 +460,7 @@ cdef class HttpParser:

if self._cparser.type == cparser.HTTP_REQUEST:
h_upg = headers.get("upgrade", "")
allowed = upgrade and h_upg.isascii() and h_upg.lower() in ALLOWED_UPGRADES
if allowed or self._cparser.method == cparser.HTTP_CONNECT:
if (upgrade and h_upg.isascii() and h_upg.lower() in ALLOWED_UPGRADES) or self._cparser.method == cparser.HTTP_CONNECT:
self._upgraded = True
else:
if upgrade and self._cparser.status_code == 101:
Expand Down
Loading