llhttp-ffi 0.3.1 → 0.5.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 +26 -15
- data/README.md +1 -1
- data/ext/aarch64-darwin/libllhttp-ext.bundle +0 -0
- data/ext/aarch64-darwin/llhttp/api.o +0 -0
- data/ext/aarch64-darwin/llhttp/http.o +0 -0
- data/ext/aarch64-darwin/llhttp/llhttp.o +0 -0
- data/ext/aarch64-darwin/llhttp/llhttp_ext.o +0 -0
- data/ext/llhttp/api.c +103 -27
- data/ext/llhttp/http.c +2 -24
- data/ext/llhttp/llhttp.c +5460 -2177
- data/ext/llhttp/llhttp.h +266 -38
- data/lib/llhttp/parser.rb +7 -1
- data/lib/llhttp/version.rb +1 -1
- data/lib/llhttp.rb +1 -0
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9720c041b7640bb1d125d8b62c758c78127a7d665c93f1d564df6b2fbaac0581
|
4
|
+
data.tar.gz: 2fde51f637fd54f90888e944ee29257aee370e7f3353c2edb4040a28539c5018
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7048b50742f8e1cb52d62906f57b5d38f5af4835ee5fe8e39c3d188409329f802423a9f278f2bbdaea59102a7313956f2ff7037158ee29aac2b29fb6b56311df
|
7
|
+
data.tar.gz: 885c7f34f7917b0bf4da8116159045f3821c010467a84e9485fd10c3418d1972e1a88127a03c3e2900a5ad9017e014997b0773f5987614ec5621d8023b64906c
|
data/CHANGELOG.md
CHANGED
@@ -1,38 +1,49 @@
|
|
1
|
-
## [v0.
|
1
|
+
## [v0.5.0](https://github.com/bryanp/llhttp/releases/tag/2023-03-29)
|
2
|
+
|
3
|
+
*released on 2023-03-29*
|
4
|
+
|
5
|
+
* `chg` [#27](https://github.com/bryanp/llhttp/pull/27) Update ffi to llhttp 8.1.0 ([bryanp](https://github.com/bryanp))
|
6
|
+
|
7
|
+
## v0.4.0
|
8
|
+
|
9
|
+
*released on 2021-09-09*
|
10
|
+
|
11
|
+
* `add` [#25](https://github.com/bryanp/llhttp/pull/25) Add support for resetting the parser ([bryanp](https://github.com/bryanp))
|
12
|
+
* `chg` [#23](https://github.com/bryanp/llhttp/pull/23) Update ffi to llhttp 6.0.5 ([bryanp](https://github.com/bryanp))
|
13
|
+
|
14
|
+
## [v0.3.1](https://github.com/bryanp/llhttp/releases/tag/2021-06-25)
|
2
15
|
|
3
16
|
*released on 2021-06-25*
|
4
17
|
|
5
|
-
* `fix` [#22](https://github.com/
|
18
|
+
* `fix` [#22](https://github.com/bryanp/llhttp/pull/22) Fix call to ffi free ([bryanp](https://github.com/bryanp))
|
6
19
|
|
7
|
-
## [v0.3.0](https://github.com/
|
20
|
+
## [v0.3.0](https://github.com/bryanp/llhttp/releases/tag/2021-05-13)
|
8
21
|
|
9
22
|
*released on 2021-05-13*
|
10
23
|
|
11
|
-
* `chg` [#19](https://github.com/
|
24
|
+
* `chg` [#19](https://github.com/bryanp/llhttp/pull/19) Add back support for Ruby 2.5 in ffi ([bryanp](https://github.com/bryanp))
|
12
25
|
|
13
|
-
## [v0.2.0](https://github.com/
|
26
|
+
## [v0.2.0](https://github.com/bryanp/llhttp/releases/tag/2021-05-06)
|
14
27
|
|
15
28
|
*released on 2021-05-06*
|
16
29
|
|
17
|
-
* `chg` [#17](https://github.com/
|
18
|
-
* `chg` [#18](https://github.com/
|
30
|
+
* `chg` [#17](https://github.com/bryanp/llhttp/pull/17) Update ffi to llhttp 6.0.1 ([bryanp](https://github.com/bryanp))
|
31
|
+
* `chg` [#18](https://github.com/bryanp/llhttp/pull/18) Drop support for Ruby 2.5 ([bryanp](https://github.com/bryanp))
|
19
32
|
|
20
|
-
## [v0.1.0](https://github.com/
|
33
|
+
## [v0.1.0](https://github.com/bryanp/llhttp/releases/tag/2021-04-06)
|
21
34
|
|
22
35
|
*released on 2021-04-06*
|
23
36
|
|
24
|
-
* `chg` [#14](https://github.com/
|
37
|
+
* `chg` [#14](https://github.com/bryanp/llhttp/pull/14) Update ffi to llhttp 5.1.0 ([bryanp](https://github.com/bryanp))
|
25
38
|
|
26
|
-
## [v0.0.1](https://github.com/
|
39
|
+
## [v0.0.1](https://github.com/bryanp/llhttp/releases/tag/2021-03-04)
|
27
40
|
|
28
41
|
*released on 2021-03-04*
|
29
42
|
|
30
|
-
* `fix` [#13](https://github.com/
|
43
|
+
* `fix` [#13](https://github.com/bryanp/llhttp/pull/13) Resolve an issue with the parser finalizer ([bryanp](https://github.com/bryanp))
|
31
44
|
|
32
|
-
## [v0.0.0](https://github.com/
|
45
|
+
## [v0.0.0](https://github.com/bryanp/llhttp/releases/tag/2021-03-03)
|
33
46
|
|
34
47
|
*released on 2021-03-03*
|
35
48
|
|
36
|
-
* `add` [#12](https://github.com/
|
37
|
-
|
38
|
-
|
49
|
+
* `add` [#12](https://github.com/bryanp/llhttp/pull/12) Introduce llhttp-ffi for better compatibility ([bryanp](https://github.com/bryanp))
|
data/README.md
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
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>
|
@@ -69,21 +46,40 @@ extern int wasm_on_url(llhttp_t* p, const char* at, size_t length);
|
|
69
46
|
extern int wasm_on_status(llhttp_t* p, const char* at, size_t length);
|
70
47
|
extern int wasm_on_header_field(llhttp_t* p, const char* at, size_t length);
|
71
48
|
extern int wasm_on_header_value(llhttp_t* p, const char* at, size_t length);
|
72
|
-
extern int wasm_on_headers_complete(llhttp_t * p
|
49
|
+
extern int wasm_on_headers_complete(llhttp_t * p, int status_code,
|
50
|
+
uint8_t upgrade, int should_keep_alive);
|
73
51
|
extern int wasm_on_body(llhttp_t* p, const char* at, size_t length);
|
74
52
|
extern int wasm_on_message_complete(llhttp_t * p);
|
75
53
|
|
54
|
+
static int wasm_on_headers_complete_wrap(llhttp_t* p) {
|
55
|
+
return wasm_on_headers_complete(p, p->status_code, p->upgrade,
|
56
|
+
llhttp_should_keep_alive(p));
|
57
|
+
}
|
58
|
+
|
76
59
|
const llhttp_settings_t wasm_settings = {
|
77
60
|
wasm_on_message_begin,
|
78
61
|
wasm_on_url,
|
79
62
|
wasm_on_status,
|
63
|
+
NULL,
|
64
|
+
NULL,
|
80
65
|
wasm_on_header_field,
|
81
66
|
wasm_on_header_value,
|
82
|
-
|
67
|
+
NULL,
|
68
|
+
NULL,
|
69
|
+
wasm_on_headers_complete_wrap,
|
83
70
|
wasm_on_body,
|
84
71
|
wasm_on_message_complete,
|
85
72
|
NULL,
|
86
73
|
NULL,
|
74
|
+
NULL,
|
75
|
+
NULL,
|
76
|
+
NULL,
|
77
|
+
NULL,
|
78
|
+
NULL,
|
79
|
+
NULL,
|
80
|
+
NULL,
|
81
|
+
NULL,
|
82
|
+
NULL,
|
87
83
|
};
|
88
84
|
|
89
85
|
|
@@ -97,6 +93,8 @@ void llhttp_free(llhttp_t* parser) {
|
|
97
93
|
free(parser);
|
98
94
|
}
|
99
95
|
|
96
|
+
#endif // defined(__wasm__)
|
97
|
+
|
100
98
|
/* Some getters required to get stuff from the parser */
|
101
99
|
|
102
100
|
uint8_t llhttp_get_type(llhttp_t* parser) {
|
@@ -123,8 +121,6 @@ uint8_t llhttp_get_upgrade(llhttp_t* parser) {
|
|
123
121
|
return parser->upgrade;
|
124
122
|
}
|
125
123
|
|
126
|
-
#endif // defined(__wasm__)
|
127
|
-
|
128
124
|
|
129
125
|
void llhttp_reset(llhttp_t* parser) {
|
130
126
|
llhttp_type_t type = parser->type;
|
@@ -243,6 +239,15 @@ const char* llhttp_method_name(llhttp_method_t method) {
|
|
243
239
|
#undef HTTP_METHOD_GEN
|
244
240
|
}
|
245
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
|
+
|
246
251
|
|
247
252
|
void llhttp_set_lenient_headers(llhttp_t* parser, int enabled) {
|
248
253
|
if (enabled) {
|
@@ -270,6 +275,14 @@ void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled) {
|
|
270
275
|
}
|
271
276
|
}
|
272
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
|
+
|
273
286
|
/* Callbacks */
|
274
287
|
|
275
288
|
|
@@ -308,6 +321,34 @@ int llhttp__on_status_complete(llhttp_t* s, const char* p, const char* endp) {
|
|
308
321
|
}
|
309
322
|
|
310
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
|
+
|
311
352
|
int llhttp__on_header_field(llhttp_t* s, const char* p, const char* endp) {
|
312
353
|
int err;
|
313
354
|
SPAN_CALLBACK_MAYBE(s, on_header_field, p, endp - p);
|
@@ -364,6 +405,34 @@ int llhttp__on_chunk_header(llhttp_t* s, const char* p, const char* endp) {
|
|
364
405
|
}
|
365
406
|
|
366
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
|
+
|
367
436
|
int llhttp__on_chunk_complete(llhttp_t* s, const char* p, const char* endp) {
|
368
437
|
int err;
|
369
438
|
CALLBACK_MAYBE(s, on_chunk_complete);
|
@@ -371,6 +440,13 @@ int llhttp__on_chunk_complete(llhttp_t* s, const char* p, const char* endp) {
|
|
371
440
|
}
|
372
441
|
|
373
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
|
+
|
374
450
|
/* Private */
|
375
451
|
|
376
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
|