Skip to content

Commit bcc416e

Browse files
[PR #7647/1303350e backport][3.8] Upgrade to llhttp 9.1.3 (#7648)
**This is a backport of PR #7647 as merged into master (1303350).** None Co-authored-by: Sam Bull <[email protected]>
1 parent b30c0cd commit bcc416e

File tree

5 files changed

+7
-3
lines changed

5 files changed

+7
-3
lines changed

aiohttp/_cparser.pxd

+2
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,5 @@ cdef extern from "../vendor/llhttp/build/llhttp.h":
154154
const char* llhttp_method_name(llhttp_method_t method)
155155

156156
void llhttp_set_lenient_headers(llhttp_t* parser, int enabled)
157+
void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled)
158+
void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled)

aiohttp/_http_parser.pyx

+2
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,8 @@ cdef class HttpResponseParser(HttpParser):
652652
# Use strict parsing on dev mode, so users are warned about broken servers.
653653
if not DEBUG:
654654
cparser.llhttp_set_lenient_headers(self._cparser, 1)
655+
cparser.llhttp_set_lenient_optional_cr_before_lf(self._cparser, 1)
656+
cparser.llhttp_set_lenient_spaces_after_chunk_size(self._cparser, 1)
655657

656658
cdef object _on_status_complete(self):
657659
if self._buf:

aiohttp/http_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def parse_headers(
498498

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

504504
return (headers, raw_headers, close_conn, encoding, upgrade, chunked)

tests/test_http_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def test_request_te_chunked_with_content_length(parser: Any) -> None:
340340
)
341341
with pytest.raises(
342342
http_exceptions.BadHttpMessage,
343-
match="Content-Length can't be present with Transfer-Encoding",
343+
match="Transfer-Encoding can't be present with Content-Length",
344344
):
345345
parser.feed_data(text)
346346

0 commit comments

Comments
 (0)