Skip to content

Commit 71e7ad2

Browse files
committed
deps: update llhttp to 9.3.0
llhttp@9.3.0 optimizes header value parsing on ARM Neon/WASM, and adds support for a protocol callback for use outside of the typical HTTP setting (RTSP/ICE).
1 parent 723d7bb commit 71e7ad2

File tree

8 files changed

+1458
-1490
lines changed

8 files changed

+1458
-1490
lines changed

deps/llhttp/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.5.1)
1+
cmake_minimum_required(VERSION 3.25.0)
22
cmake_policy(SET CMP0069 NEW)
33

4-
project(llhttp VERSION 9.2.1)
4+
project(llhttp VERSION 9.3.0)
55
include(GNUInstallDirs)
66

77
set(CMAKE_C_STANDARD 99)
@@ -49,7 +49,7 @@ function(config_library target)
4949

5050
target_include_directories(${target} PUBLIC
5151
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
52-
$<INSTALL_INTERFACE:include>
52+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
5353
)
5454

5555
set_target_properties(${target} PROPERTIES
@@ -61,6 +61,7 @@ function(config_library target)
6161

6262
install(TARGETS ${target}
6363
EXPORT llhttp
64+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
6465
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
6566
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
6667
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}

deps/llhttp/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
This software is licensed under the MIT License.
2+
3+
Copyright Fedor Indutny, 2018.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a
6+
copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to permit
10+
persons to whom the Software is furnished to do so, subject to the
11+
following conditions:
12+
13+
The above copyright notice and this permission notice shall be included
14+
in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22+
USE OR OTHER DEALINGS IN THE SOFTWARE.

deps/llhttp/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ int main() {
9494
if (err == HPE_OK) {
9595
fprintf(stdout, "Successfully parsed!\n");
9696
} else {
97-
fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err), parser.reason);
97+
fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err), llhttp_get_error_reason(&parser));
9898
}
9999
}
100100
```
@@ -112,6 +112,7 @@ The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_
112112
* `on_message_complete`: Invoked when a request/response has been completedly parsed.
113113
* `on_url_complete`: Invoked after the URL has been parsed.
114114
* `on_method_complete`: Invoked after the HTTP method has been parsed.
115+
* `on_protocol_complete`: Invoked after the HTTP version has been parsed.
115116
* `on_version_complete`: Invoked after the HTTP version has been parsed.
116117
* `on_status_complete`: Invoked after the status code has been parsed.
117118
* `on_header_field_complete`: Invoked after a header name has been parsed.
@@ -130,6 +131,7 @@ The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_
130131
* `on_method`: Invoked when another character of the method is received.
131132
When parser is created with `HTTP_BOTH` and the input is a response, this also invoked for the sequence `HTTP/`
132133
of the first message.
134+
* `on_protocol`: Invoked when another character of the protocol is received.
133135
* `on_version`: Invoked when another character of the version is received.
134136
* `on_header_field`: Invoked when another character of a header name is received.
135137
* `on_header_value`: Invoked when another character of a header value is received.
@@ -187,7 +189,8 @@ Parse full or partial request/response, invoking user callbacks along the way.
187189
188190
If any of `llhttp_data_cb` returns errno not equal to `HPE_OK` - the parsing interrupts,
189191
and such errno is returned from `llhttp_execute()`. If `HPE_PAUSED` was used as a errno,
190-
the execution can be resumed with `llhttp_resume()` call.
192+
the execution can be resumed with `llhttp_resume()` call. In that case the input should be advanced
193+
to the last processed byte from the parser, which can be obtained via `llhttp_get_error_pos()`.
191194
192195
In a special case of CONNECT/Upgrade request/response `HPE_PAUSED_UPGRADE` is returned
193196
after fully parsing the request/response. If the user wishes to continue parsing,
@@ -196,6 +199,8 @@ they need to invoke `llhttp_resume_after_upgrade()`.
196199
**if this function ever returns a non-pause type error, it will continue to return
197200
the same error upon each successive call up until `llhttp_init()` is called.**
198201
202+
If this function returns `HPE_OK`, it means all the input has been consumed and parsed.
203+
199204
### `llhttp_errno_t llhttp_finish(llhttp_t* parser)`
200205
201206
This method should be called when the other side has no further bytes to

deps/llhttp/include/llhttp.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#define INCLUDE_LLHTTP_H_
44

55
#define LLHTTP_VERSION_MAJOR 9
6-
#define LLHTTP_VERSION_MINOR 2
7-
#define LLHTTP_VERSION_PATCH 1
6+
#define LLHTTP_VERSION_MINOR 3
7+
#define LLHTTP_VERSION_PATCH 0
88

99
#ifndef INCLUDE_LLHTTP_ITSELF_H_
1010
#define INCLUDE_LLHTTP_ITSELF_H_
@@ -90,7 +90,8 @@ enum llhttp_errno {
9090
HPE_CB_HEADER_VALUE_COMPLETE = 29,
9191
HPE_CB_CHUNK_EXTENSION_NAME_COMPLETE = 34,
9292
HPE_CB_CHUNK_EXTENSION_VALUE_COMPLETE = 35,
93-
HPE_CB_RESET = 31
93+
HPE_CB_RESET = 31,
94+
HPE_CB_PROTOCOL_COMPLETE = 38
9495
};
9596
typedef enum llhttp_errno llhttp_errno_t;
9697

@@ -326,6 +327,7 @@ typedef enum llhttp_status llhttp_status_t;
326327
XX(34, CB_CHUNK_EXTENSION_NAME_COMPLETE, CB_CHUNK_EXTENSION_NAME_COMPLETE) \
327328
XX(35, CB_CHUNK_EXTENSION_VALUE_COMPLETE, CB_CHUNK_EXTENSION_VALUE_COMPLETE) \
328329
XX(31, CB_RESET, CB_RESET) \
330+
XX(38, CB_PROTOCOL_COMPLETE, CB_PROTOCOL_COMPLETE) \
329331

330332

331333
#define HTTP_METHOD_MAP(XX) \
@@ -567,6 +569,7 @@ struct llhttp_settings_s {
567569
llhttp_cb on_message_begin;
568570

569571
/* Possible return values 0, -1, HPE_USER */
572+
llhttp_data_cb on_protocol;
570573
llhttp_data_cb on_url;
571574
llhttp_data_cb on_status;
572575
llhttp_data_cb on_method;
@@ -592,6 +595,7 @@ struct llhttp_settings_s {
592595

593596
/* Possible return values 0, -1, `HPE_PAUSED` */
594597
llhttp_cb on_message_complete;
598+
llhttp_cb on_protocol_complete;
595599
llhttp_cb on_url_complete;
596600
llhttp_cb on_status_complete;
597601
llhttp_cb on_method_complete;

deps/llhttp/libllhttp.pc.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
prefix=@CMAKE_INSTALL_PREFIX@
2-
exec_prefix=@CMAKE_INSTALL_PREFIX@
3-
libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
4-
includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@
2+
exec_prefix=@CMAKE_INSTALL_FULL_BINDIR@
3+
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
4+
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
55

66
Name: libllhttp
77
Description: Node.js llhttp Library
88
Version: @PROJECT_VERSION@
99
Libs: -L${libdir} -lllhttp
10-
Cflags: -I${includedir}
10+
Cflags: -I${includedir}

deps/llhttp/src/api.c

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,14 @@ static int wasm_on_headers_complete_wrap(llhttp_t* p) {
5757
}
5858

5959
const llhttp_settings_t wasm_settings = {
60-
wasm_on_message_begin,
61-
wasm_on_url,
62-
wasm_on_status,
63-
NULL,
64-
NULL,
65-
wasm_on_header_field,
66-
wasm_on_header_value,
67-
NULL,
68-
NULL,
69-
wasm_on_headers_complete_wrap,
70-
wasm_on_body,
71-
wasm_on_message_complete,
72-
NULL,
73-
NULL,
74-
NULL,
75-
NULL,
76-
NULL,
77-
NULL,
78-
NULL,
79-
NULL,
80-
NULL,
81-
NULL,
82-
NULL,
60+
.on_message_begin = wasm_on_message_begin,
61+
.on_url = wasm_on_url,
62+
.on_status = wasm_on_status,
63+
.on_header_field = wasm_on_header_field,
64+
.on_header_value = wasm_on_header_value,
65+
.on_headers_complete = wasm_on_headers_complete_wrap,
66+
.on_body = wasm_on_body,
67+
.on_message_complete = wasm_on_message_complete,
8368
};
8469

8570

@@ -341,6 +326,20 @@ int llhttp__on_message_begin(llhttp_t* s, const char* p, const char* endp) {
341326
}
342327

343328

329+
int llhttp__on_protocol(llhttp_t* s, const char* p, const char* endp) {
330+
int err;
331+
SPAN_CALLBACK_MAYBE(s, on_protocol, p, endp - p);
332+
return err;
333+
}
334+
335+
336+
int llhttp__on_protocol_complete(llhttp_t* s, const char* p, const char* endp) {
337+
int err;
338+
CALLBACK_MAYBE(s, on_protocol_complete);
339+
return err;
340+
}
341+
342+
344343
int llhttp__on_url(llhttp_t* s, const char* p, const char* endp) {
345344
int err;
346345
SPAN_CALLBACK_MAYBE(s, on_url, p, endp - p);

0 commit comments

Comments
 (0)