Skip to content

Commit 8a92830

Browse files
indutnytargos
authored andcommitted
deps: update llhttp to 2.0.1
Changelog: * Optional SSE4.2 support (at compile time) * Lenient mode of operation PR-URL: #30553 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Myles Borins <[email protected]>
1 parent a2f3f60 commit 8a92830

File tree

5 files changed

+306
-115
lines changed

5 files changed

+306
-115
lines changed

deps/llhttp/README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This project aims to:
1414
* Verifiable
1515
* Improving benchmarks where possible
1616

17+
More details in [Fedor Indutny's talk at JSConf EU 2019](https://youtu.be/x3k_5Mi66sY)
18+
1719
## How?
1820

1921
Over time, different approaches for improving [http_parser][0]'s code base
@@ -30,11 +32,10 @@ So far llhttp outperforms http_parser:
3032

3133
| | input size | bandwidth | reqs/sec | time |
3234
|:----------------|-----------:|-------------:|-----------:|--------:|
33-
| **llhttp** _(C)_ | 8192.00 mb | 1497.88 mb/s | 3020458.87 ops/sec | 5.47 s |
34-
| **llhttp** _(bitcode)_ | 8192.00 mb | 1131.75 mb/s | 2282171.24 ops/sec | 7.24 s |
35+
| **llhttp** _(C)_ | 8192.00 mb | 1777.24 mb/s | 3583799.39 ops/sec | 4.61 s |
3536
| **http_parser** | 8192.00 mb | 694.66 mb/s | 1406180.33 req/sec | 11.79 s |
3637

37-
llhttp is faster by approximately **116%**.
38+
llhttp is faster by approximately **156%**.
3839

3940
## Maintenance
4041

@@ -77,8 +78,6 @@ settings.on_message_complete = handle_on_message_complete;
7778
*/
7879
llhttp_init(&parser, HTTP_BOTH, &settings);
7980

80-
/* Use `llhttp_set_type(&parser, HTTP_REQUEST);` to override the mode */
81-
8281
/* Parse request! */
8382
const char* request = "GET / HTTP/1.1\r\n\r\n";
8483
int request_len = strlen(request);

deps/llhttp/include/llhttp.h

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef INCLUDE_LLHTTP_H_
22
#define INCLUDE_LLHTTP_H_
33

4-
#define LLHTTP_VERSION_MAJOR 1
5-
#define LLHTTP_VERSION_MINOR 1
6-
#define LLHTTP_VERSION_PATCH 4
4+
#define LLHTTP_VERSION_MAJOR 2
5+
#define LLHTTP_VERSION_MINOR 0
6+
#define LLHTTP_VERSION_PATCH 1
77

88
#ifndef INCLUDE_LLHTTP_ITSELF_H_
99
#define INCLUDE_LLHTTP_ITSELF_H_
@@ -29,7 +29,7 @@ struct llhttp__internal_s {
2929
uint8_t http_major;
3030
uint8_t http_minor;
3131
uint8_t header_state;
32-
uint8_t flags;
32+
uint16_t flags;
3333
uint8_t upgrade;
3434
uint16_t status_code;
3535
uint8_t finish;
@@ -85,7 +85,8 @@ enum llhttp_flags {
8585
F_UPGRADE = 0x10,
8686
F_CONTENT_LENGTH = 0x20,
8787
F_SKIPBODY = 0x40,
88-
F_TRAILING = 0x80
88+
F_TRAILING = 0x80,
89+
F_LENIENT = 0x100
8990
};
9091
typedef enum llhttp_flags llhttp_flags_t;
9192

@@ -297,7 +298,7 @@ llhttp_errno_t llhttp_finish(llhttp_t* parser);
297298
int llhttp_message_needs_eof(const llhttp_t* parser);
298299

299300
/* Returns `1` if there might be any other messages following the last that was
300-
* successfuly parsed.
301+
* successfully parsed.
301302
*/
302303
int llhttp_should_keep_alive(const llhttp_t* parser);
303304

@@ -353,6 +354,18 @@ const char* llhttp_errno_name(llhttp_errno_t err);
353354
/* Returns textual name of HTTP method */
354355
const char* llhttp_method_name(llhttp_method_t method);
355356

357+
358+
/* Enables/disables lenient header value parsing (disabled by default).
359+
*
360+
* Lenient parsing disables header value token checks, extending llhttp's
361+
* protocol support to highly non-compliant clients/server. No
362+
* `HPE_INVALID_HEADER_TOKEN` will be raised for incorrect header values when
363+
* lenient parsing is "on".
364+
*
365+
* **(USE AT YOUR OWN RISK)**
366+
*/
367+
void llhttp_set_lenient(llhttp_t* parser, int enabled);
368+
356369
#ifdef __cplusplus
357370
} /* extern "C" */
358371
#endif

deps/llhttp/src/api.c

+9
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ const char* llhttp_method_name(llhttp_method_t method) {
127127
}
128128

129129

130+
void llhttp_set_lenient(llhttp_t* parser, int enabled) {
131+
if (enabled) {
132+
parser->flags |= F_LENIENT;
133+
} else {
134+
parser->flags &= ~F_LENIENT;
135+
}
136+
}
137+
138+
130139
/* Callbacks */
131140

132141

deps/llhttp/src/http.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ int llhttp__after_message_complete(llhttp_t* parser, const char* p,
7474
int should_keep_alive;
7575

7676
should_keep_alive = llhttp_should_keep_alive(parser);
77-
parser->flags = 0;
7877
parser->finish = HTTP_FINISH_SAFE;
7978

79+
/* Keep `F_LENIENT` flag between messages, but reset every other flag */
80+
parser->flags &= F_LENIENT;
81+
8082
/* NOTE: this is ignored in loose parsing mode */
8183
return should_keep_alive;
8284
}

0 commit comments

Comments
 (0)