Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #7647/1303350e backport][3.8] Upgrade to llhttp 9.1.3 #7648

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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