Skip to content

Commit f92b27b

Browse files
Update to LLHTTP 9 (#7485) (#7487)
(cherry picked from commit c0c7508)
1 parent 8129d26 commit f92b27b

File tree

6 files changed

+8
-52
lines changed

6 files changed

+8
-52
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "vendor/llhttp"]
22
path = vendor/llhttp
33
url = https://github.com/nodejs/llhttp.git
4-
branch = v8.x
4+
branch = main

CHANGES/7484.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgraded llhttp parser to v9 -- by :user:`Dreamsorcerer`

aiohttp/_cparser.pxd

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
from libc.stdint cimport (
2-
int8_t,
3-
int16_t,
4-
int32_t,
5-
int64_t,
6-
uint8_t,
7-
uint16_t,
8-
uint32_t,
9-
uint64_t,
10-
)
1+
from libc.stdint cimport int32_t, uint8_t, uint16_t, uint64_t
112

123

134
cdef extern from "../vendor/llhttp/build/llhttp.h":
@@ -88,30 +79,14 @@ cdef extern from "../vendor/llhttp/build/llhttp.h":
8879
ctypedef llhttp_errno llhttp_errno_t
8980

9081
enum llhttp_flags:
91-
F_CONNECTION_KEEP_ALIVE,
92-
F_CONNECTION_CLOSE,
93-
F_CONNECTION_UPGRADE,
9482
F_CHUNKED,
95-
F_UPGRADE,
96-
F_CONTENT_LENGTH,
97-
F_SKIPBODY,
98-
F_TRAILING,
99-
F_TRANSFER_ENCODING
100-
101-
enum llhttp_lenient_flags:
102-
LENIENT_HEADERS,
103-
LENIENT_CHUNKED_LENGTH
83+
F_CONTENT_LENGTH
10484

10585
enum llhttp_type:
10686
HTTP_REQUEST,
10787
HTTP_RESPONSE,
10888
HTTP_BOTH
10989

110-
enum llhttp_finish_t:
111-
HTTP_FINISH_SAFE,
112-
HTTP_FINISH_SAFE_WITH_CB,
113-
HTTP_FINISH_UNSAFE
114-
11590
enum llhttp_method:
11691
HTTP_DELETE,
11792
HTTP_GET,
@@ -167,24 +142,15 @@ cdef extern from "../vendor/llhttp/build/llhttp.h":
167142
const llhttp_settings_t* settings)
168143

169144
llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len)
170-
llhttp_errno_t llhttp_finish(llhttp_t* parser)
171-
172-
int llhttp_message_needs_eof(const llhttp_t* parser)
173145

174146
int llhttp_should_keep_alive(const llhttp_t* parser)
175147

176-
void llhttp_pause(llhttp_t* parser)
177-
void llhttp_resume(llhttp_t* parser)
178-
179148
void llhttp_resume_after_upgrade(llhttp_t* parser)
180149

181150
llhttp_errno_t llhttp_get_errno(const llhttp_t* parser)
182151
const char* llhttp_get_error_reason(const llhttp_t* parser)
183-
void llhttp_set_error_reason(llhttp_t* parser, const char* reason)
184152
const char* llhttp_get_error_pos(const llhttp_t* parser)
185-
const char* llhttp_errno_name(llhttp_errno_t err)
186153

187154
const char* llhttp_method_name(llhttp_method_t method)
188155

189156
void llhttp_set_lenient_headers(llhttp_t* parser, int enabled)
190-
void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled)

tests/test_http_parser.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -861,19 +861,6 @@ def test_partial_url(parser) -> None:
861861
assert payload.is_eof()
862862

863863

864-
def test_url_parse_non_strict_mode(parser) -> None:
865-
payload = "GET /test/тест HTTP/1.1\r\n\r\n".encode()
866-
messages, upgrade, tail = parser.feed_data(payload)
867-
assert len(messages) == 1
868-
869-
msg, payload = messages[0]
870-
871-
assert msg.method == "GET"
872-
assert msg.path == "/test/тест"
873-
assert msg.version == (1, 1)
874-
assert payload.is_eof()
875-
876-
877864
@pytest.mark.parametrize(
878865
("uri", "path", "query", "fragment"),
879866
[
@@ -898,6 +885,8 @@ def test_parse_uri_percent_encoded(parser, uri, path, query, fragment) -> None:
898885

899886

900887
def test_parse_uri_utf8(parser) -> None:
888+
if not isinstance(parser, HttpRequestParserPy):
889+
pytest.xfail("Not valid HTTP. Maybe update py-parser to reject later.")
901890
text = ("GET /путь?ключ=знач#фраг HTTP/1.1\r\n\r\n").encode()
902891
messages, upgrade, tail = parser.feed_data(text)
903892
msg = messages[0][0]

vendor/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ When building aiohttp from source, there is a pure Python parser used by default
55
For better performance, you may want to build the higher performance C parser.
66

77
To build this ``llhttp`` parser, first get/update the submodules (to update to a
8-
newer release, add ``--remote`` and check the branch in ``.gitmodules``)::
8+
newer release, add ``--remote``)::
99

1010
git submodule update --init --recursive
1111

0 commit comments

Comments
 (0)