llhttp 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -22
- data/ext/llhttp/api.c +95 -25
- data/ext/llhttp/http.c +2 -24
- data/ext/llhttp/llhttp.c +5453 -2170
- data/ext/llhttp/llhttp.h +266 -38
- data/ext/llhttp/llhttp_ext.c +106 -69
- data/lib/llhttp/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5042607c857885f7e9e276ef979465caf2eea262e766d4c28938887d8933f173
|
4
|
+
data.tar.gz: 00531eed2651d3f9f9800d47252d6998c9d1e4d9f9a577a8fe8f6b04f92874be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb65e98b9bb0f61bbd86949136fdbf0be367f28e0698169a848244d3ba88e521b71cbe7c845f4afddd8606d18b8363675cd4818bb9e6ca4184554f2ad85997fa
|
7
|
+
data.tar.gz: d6f1ef8087034637698d20bd0c547382104ab964850bef893f64dc9ed269692955d6fbb229cce9e066253e663f2ffb8223ab8650e2e17e9853c86490ac7e566d
|
data/CHANGELOG.md
CHANGED
@@ -1,51 +1,61 @@
|
|
1
|
-
## v0.
|
1
|
+
## [v0.6.0](https://github.com/bryanp/llhttp/releases/tag/2023-03-29)
|
2
|
+
|
3
|
+
*released on 2023-03-29*
|
4
|
+
|
5
|
+
* `chg` [#28](https://github.com/bryanp/llhttp/pull/28) Update mri to llhttp 8.1.0 ([bryanp](https://github.com/bryanp))
|
6
|
+
|
7
|
+
## [v0.5.0](https://github.com/bryanp/llhttp/releases/tag/2021-09-21)
|
8
|
+
|
9
|
+
*released on 2021-09-21*
|
10
|
+
|
11
|
+
* `chg` [#26](https://github.com/bryanp/llhttp/pull/26) Refactor parser data to include all values ([bryanp](https://github.com/bryanp))
|
12
|
+
|
13
|
+
## [v0.4.0](https://github.com/bryanp/llhttp/releases/tag/2021-09-09)
|
2
14
|
|
3
15
|
*released on 2021-09-09*
|
4
16
|
|
5
|
-
* `add` [#25](https://github.com/
|
6
|
-
* `chg` [#24](https://github.com/
|
17
|
+
* `add` [#25](https://github.com/bryanp/llhttp/pull/25) Add support for resetting the parser ([bryanp](https://github.com/bryanp))
|
18
|
+
* `chg` [#24](https://github.com/bryanp/llhttp/pull/24) Update mri to llhttp 6.0.5 ([bryanp](https://github.com/bryanp))
|
7
19
|
|
8
|
-
## v0.3.0
|
20
|
+
## [v0.3.0](https://github.com/bryanp/llhttp/releases/tag/2021-05-06)
|
9
21
|
|
10
22
|
*released on 2021-05-06*
|
11
23
|
|
12
|
-
* `chg` [#16](https://github.com/
|
13
|
-
* `chg` [#18](https://github.com/
|
24
|
+
* `chg` [#16](https://github.com/bryanp/llhttp/pull/16) Update mri to llhttp 6.0.1 ([bryanp](https://github.com/bryanp))
|
25
|
+
* `chg` [#18](https://github.com/bryanp/llhttp/pull/18) Drop support for Ruby 2.5 ([bryanp](https://github.com/bryanp))
|
14
26
|
|
15
|
-
## [v0.2.0](https://github.com/
|
27
|
+
## [v0.2.0](https://github.com/bryanp/llhttp/releases/tag/2021-04-06)
|
16
28
|
|
17
29
|
*released on 2021-04-06*
|
18
30
|
|
19
|
-
* `chg` [#15](https://github.com/
|
31
|
+
* `chg` [#15](https://github.com/bryanp/llhttp/pull/15) Update mri to llhttp 5.1.0 ([bryanp](https://github.com/bryanp))
|
20
32
|
|
21
|
-
## [v0.1.0](https://github.com/
|
33
|
+
## [v0.1.0](https://github.com/bryanp/llhttp/releases/tag/2021-03-03)
|
22
34
|
|
23
35
|
*released on 2021-03-03*
|
24
36
|
|
25
|
-
* `chg` [#11](https://github.com/
|
26
|
-
* `chg` [#10](https://github.com/
|
27
|
-
* `chg` [#9](https://github.com/
|
28
|
-
* `add` [#2](https://github.com/
|
29
|
-
* `add` [#8](https://github.com/
|
30
|
-
* `chg` [#7](https://github.com/
|
31
|
-
* `chg` [#6](https://github.com/
|
37
|
+
* `chg` [#11](https://github.com/bryanp/llhttp/pull/11) Rename Parser#method to Parser#method_name ([bryanp](https://github.com/bryanp))
|
38
|
+
* `chg` [#10](https://github.com/bryanp/llhttp/pull/10) Only setup callbacks if they are defined on the delegate ([bryanp](https://github.com/bryanp))
|
39
|
+
* `chg` [#9](https://github.com/bryanp/llhttp/pull/9) Update llhttp to 4.0.0 ([bryanp](https://github.com/bryanp))
|
40
|
+
* `add` [#2](https://github.com/bryanp/llhttp/pull/2) Support introspection of http major/minor version ([midnight-wonderer](https://github.com/midnight-wonderer))
|
41
|
+
* `add` [#8](https://github.com/bryanp/llhttp/pull/8) Support new *_complete callbacks ([bryanp](https://github.com/bryanp))
|
42
|
+
* `chg` [#7](https://github.com/bryanp/llhttp/pull/7) Return an error status from the appropriate callbacks ([bryanp](https://github.com/bryanp))
|
43
|
+
* `chg` [#6](https://github.com/bryanp/llhttp/pull/6) Update llhttp to 3.0.1 ([bryanp](https://github.com/bryanp))
|
32
44
|
|
33
|
-
## [v0.0.3](https://github.com/
|
45
|
+
## [v0.0.3](https://github.com/bryanp/llhttp/releases/tag/v0.0.3)
|
34
46
|
|
35
47
|
*released on 2020-12-30*
|
36
48
|
|
37
|
-
* `fix` [#5](https://github.com/
|
49
|
+
* `fix` [#5](https://github.com/bryanp/llhttp/pull/5) Build the extension correctly ([bryanp](https://github.com/bryanp))
|
38
50
|
|
39
|
-
## [v0.0.2](https://github.com/
|
51
|
+
## [v0.0.2](https://github.com/bryanp/llhttp/releases/tag/v0.0.2)
|
40
52
|
|
41
53
|
*released on 2020-10-11*
|
42
54
|
|
43
55
|
* `fix` Correctly free parser settings when freeing the parser.
|
44
56
|
|
45
|
-
## [v0.0.1](https://github.com/
|
57
|
+
## [v0.0.1](https://github.com/bryanp/llhttp/releases/tag/v0.0.1)
|
46
58
|
|
47
59
|
*released on 2020-10-11*
|
48
60
|
|
49
61
|
* Initial release.
|
50
|
-
|
51
|
-
|
data/ext/llhttp/api.c
CHANGED
@@ -1,26 +1,3 @@
|
|
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.
|
23
|
-
|
24
1
|
#include <stdlib.h>
|
25
2
|
#include <stdio.h>
|
26
3
|
#include <string.h>
|
@@ -83,13 +60,26 @@ const llhttp_settings_t wasm_settings = {
|
|
83
60
|
wasm_on_message_begin,
|
84
61
|
wasm_on_url,
|
85
62
|
wasm_on_status,
|
63
|
+
NULL,
|
64
|
+
NULL,
|
86
65
|
wasm_on_header_field,
|
87
66
|
wasm_on_header_value,
|
67
|
+
NULL,
|
68
|
+
NULL,
|
88
69
|
wasm_on_headers_complete_wrap,
|
89
70
|
wasm_on_body,
|
90
71
|
wasm_on_message_complete,
|
91
72
|
NULL,
|
92
73
|
NULL,
|
74
|
+
NULL,
|
75
|
+
NULL,
|
76
|
+
NULL,
|
77
|
+
NULL,
|
78
|
+
NULL,
|
79
|
+
NULL,
|
80
|
+
NULL,
|
81
|
+
NULL,
|
82
|
+
NULL,
|
93
83
|
};
|
94
84
|
|
95
85
|
|
@@ -103,6 +93,8 @@ void llhttp_free(llhttp_t* parser) {
|
|
103
93
|
free(parser);
|
104
94
|
}
|
105
95
|
|
96
|
+
#endif // defined(__wasm__)
|
97
|
+
|
106
98
|
/* Some getters required to get stuff from the parser */
|
107
99
|
|
108
100
|
uint8_t llhttp_get_type(llhttp_t* parser) {
|
@@ -129,8 +121,6 @@ uint8_t llhttp_get_upgrade(llhttp_t* parser) {
|
|
129
121
|
return parser->upgrade;
|
130
122
|
}
|
131
123
|
|
132
|
-
#endif // defined(__wasm__)
|
133
|
-
|
134
124
|
|
135
125
|
void llhttp_reset(llhttp_t* parser) {
|
136
126
|
llhttp_type_t type = parser->type;
|
@@ -249,6 +239,15 @@ const char* llhttp_method_name(llhttp_method_t method) {
|
|
249
239
|
#undef HTTP_METHOD_GEN
|
250
240
|
}
|
251
241
|
|
242
|
+
const char* llhttp_status_name(llhttp_status_t status) {
|
243
|
+
#define HTTP_STATUS_GEN(NUM, NAME, STRING) case HTTP_STATUS_##NAME: return #STRING;
|
244
|
+
switch (status) {
|
245
|
+
HTTP_STATUS_MAP(HTTP_STATUS_GEN)
|
246
|
+
default: abort();
|
247
|
+
}
|
248
|
+
#undef HTTP_STATUS_GEN
|
249
|
+
}
|
250
|
+
|
252
251
|
|
253
252
|
void llhttp_set_lenient_headers(llhttp_t* parser, int enabled) {
|
254
253
|
if (enabled) {
|
@@ -276,6 +275,14 @@ void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled) {
|
|
276
275
|
}
|
277
276
|
}
|
278
277
|
|
278
|
+
void llhttp_set_lenient_transfer_encoding(llhttp_t* parser, int enabled) {
|
279
|
+
if (enabled) {
|
280
|
+
parser->lenient_flags |= LENIENT_TRANSFER_ENCODING;
|
281
|
+
} else {
|
282
|
+
parser->lenient_flags &= ~LENIENT_TRANSFER_ENCODING;
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
279
286
|
/* Callbacks */
|
280
287
|
|
281
288
|
|
@@ -314,6 +321,34 @@ int llhttp__on_status_complete(llhttp_t* s, const char* p, const char* endp) {
|
|
314
321
|
}
|
315
322
|
|
316
323
|
|
324
|
+
int llhttp__on_method(llhttp_t* s, const char* p, const char* endp) {
|
325
|
+
int err;
|
326
|
+
SPAN_CALLBACK_MAYBE(s, on_method, p, endp - p);
|
327
|
+
return err;
|
328
|
+
}
|
329
|
+
|
330
|
+
|
331
|
+
int llhttp__on_method_complete(llhttp_t* s, const char* p, const char* endp) {
|
332
|
+
int err;
|
333
|
+
CALLBACK_MAYBE(s, on_method_complete);
|
334
|
+
return err;
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
int llhttp__on_version(llhttp_t* s, const char* p, const char* endp) {
|
339
|
+
int err;
|
340
|
+
SPAN_CALLBACK_MAYBE(s, on_version, p, endp - p);
|
341
|
+
return err;
|
342
|
+
}
|
343
|
+
|
344
|
+
|
345
|
+
int llhttp__on_version_complete(llhttp_t* s, const char* p, const char* endp) {
|
346
|
+
int err;
|
347
|
+
CALLBACK_MAYBE(s, on_version_complete);
|
348
|
+
return err;
|
349
|
+
}
|
350
|
+
|
351
|
+
|
317
352
|
int llhttp__on_header_field(llhttp_t* s, const char* p, const char* endp) {
|
318
353
|
int err;
|
319
354
|
SPAN_CALLBACK_MAYBE(s, on_header_field, p, endp - p);
|
@@ -370,6 +405,34 @@ int llhttp__on_chunk_header(llhttp_t* s, const char* p, const char* endp) {
|
|
370
405
|
}
|
371
406
|
|
372
407
|
|
408
|
+
int llhttp__on_chunk_extension_name(llhttp_t* s, const char* p, const char* endp) {
|
409
|
+
int err;
|
410
|
+
SPAN_CALLBACK_MAYBE(s, on_chunk_extension_name, p, endp - p);
|
411
|
+
return err;
|
412
|
+
}
|
413
|
+
|
414
|
+
|
415
|
+
int llhttp__on_chunk_extension_name_complete(llhttp_t* s, const char* p, const char* endp) {
|
416
|
+
int err;
|
417
|
+
CALLBACK_MAYBE(s, on_chunk_extension_name_complete);
|
418
|
+
return err;
|
419
|
+
}
|
420
|
+
|
421
|
+
|
422
|
+
int llhttp__on_chunk_extension_value(llhttp_t* s, const char* p, const char* endp) {
|
423
|
+
int err;
|
424
|
+
SPAN_CALLBACK_MAYBE(s, on_chunk_extension_value, p, endp - p);
|
425
|
+
return err;
|
426
|
+
}
|
427
|
+
|
428
|
+
|
429
|
+
int llhttp__on_chunk_extension_value_complete(llhttp_t* s, const char* p, const char* endp) {
|
430
|
+
int err;
|
431
|
+
CALLBACK_MAYBE(s, on_chunk_extension_value_complete);
|
432
|
+
return err;
|
433
|
+
}
|
434
|
+
|
435
|
+
|
373
436
|
int llhttp__on_chunk_complete(llhttp_t* s, const char* p, const char* endp) {
|
374
437
|
int err;
|
375
438
|
CALLBACK_MAYBE(s, on_chunk_complete);
|
@@ -377,6 +440,13 @@ int llhttp__on_chunk_complete(llhttp_t* s, const char* p, const char* endp) {
|
|
377
440
|
}
|
378
441
|
|
379
442
|
|
443
|
+
int llhttp__on_reset(llhttp_t* s, const char* p, const char* endp) {
|
444
|
+
int err;
|
445
|
+
CALLBACK_MAYBE(s, on_reset);
|
446
|
+
return err;
|
447
|
+
}
|
448
|
+
|
449
|
+
|
380
450
|
/* Private */
|
381
451
|
|
382
452
|
|
data/ext/llhttp/http.c
CHANGED
@@ -1,26 +1,3 @@
|
|
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.
|
23
|
-
|
24
1
|
#include <stdio.h>
|
25
2
|
#ifndef LLHTTP__TEST
|
26
3
|
# include "llhttp.h"
|
@@ -75,7 +52,8 @@ int llhttp__after_headers_complete(llhttp_t* parser, const char* p,
|
|
75
52
|
return 2;
|
76
53
|
} else if (parser->flags & F_TRANSFER_ENCODING) {
|
77
54
|
if (parser->type == HTTP_REQUEST &&
|
78
|
-
(parser->lenient_flags & LENIENT_CHUNKED_LENGTH) == 0
|
55
|
+
(parser->lenient_flags & LENIENT_CHUNKED_LENGTH) == 0 &&
|
56
|
+
(parser->lenient_flags & LENIENT_TRANSFER_ENCODING) == 0) {
|
79
57
|
/* RFC 7230 3.3.3 */
|
80
58
|
|
81
59
|
/* If a Transfer-Encoding header field
|