Skip to content

Commit

Permalink
[PR #7647/1303350e backport][3.8] Upgrade to llhttp 9.1.3 (#7648)
Browse files Browse the repository at this point in the history
**This is a backport of PR #7647 as merged into master
(1303350).**

None

Co-authored-by: Sam Bull <git@sambull.org>
  • Loading branch information
patchback[bot] and Dreamsorcerer authored Oct 3, 2023
1 parent b30c0cd commit bcc416e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions aiohttp/_cparser.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ cdef extern from "../vendor/llhttp/build/llhttp.h":
const char* llhttp_method_name(llhttp_method_t method)

void llhttp_set_lenient_headers(llhttp_t* parser, int enabled)
void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled)
void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled)
2 changes: 2 additions & 0 deletions aiohttp/_http_parser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@ cdef class HttpResponseParser(HttpParser):
# Use strict parsing on dev mode, so users are warned about broken servers.
if not DEBUG:
cparser.llhttp_set_lenient_headers(self._cparser, 1)
cparser.llhttp_set_lenient_optional_cr_before_lf(self._cparser, 1)
cparser.llhttp_set_lenient_spaces_after_chunk_size(self._cparser, 1)

cdef object _on_status_complete(self):
if self._buf:
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def parse_headers(

if hdrs.CONTENT_LENGTH in headers:
raise BadHttpMessage(
"Content-Length can't be present with Transfer-Encoding",
"Transfer-Encoding can't be present with Content-Length",
)

return (headers, raw_headers, close_conn, encoding, upgrade, chunked)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def test_request_te_chunked_with_content_length(parser: Any) -> None:
)
with pytest.raises(
http_exceptions.BadHttpMessage,
match="Content-Length can't be present with Transfer-Encoding",
match="Transfer-Encoding can't be present with Content-Length",
):
parser.feed_data(text)

Expand Down

0 comments on commit bcc416e

Please sign in to comment.