llhttp-ffi 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6af451609178568c6487f75fcece2bf8915e0bec6fd51a44761598382afa5de
4
- data.tar.gz: 037b38718ded224ec48808f183b1bf9a5e8f65949eaf0fd64379657233521bd1
3
+ metadata.gz: 702d7047da5b1893a33738b779197039a335b983cd803bda251a470045b52c34
4
+ data.tar.gz: c01172f662009de49ab60252eec448fddcb583dbfc0e5c6ba16724ea3326d5de
5
5
  SHA512:
6
- metadata.gz: 2947c990fdb5a4909d2c631e417bff9e9003b04d0f7fed674d01d7328f75dab2766d1ec4f3aa591267f94c3cf03be352d6aaebe176a49558703675ba3cc087b7
7
- data.tar.gz: 5feb106a0e5f6e92cd1f63b506bc84af6add70565cc1f603a4cdb55ae7af2cbc71bf4f1a68df02b1238bdf25bf08e58255cbc010141817081986578d5b9d1645
6
+ metadata.gz: dd6c702961011ca56355c3d7b829ab261e30eb885ef69f666fc6a4399d5bf7062f2cbea4bd4686b27600b04096fd831ce404602a99a6fdc28a2110b59948d750
7
+ data.tar.gz: fbdd9712f826af82c29c95af8df4e75de4e3b085aca85ad8bb1baaebf5b1d2c820b7bc14bb850052f8b5b6ed104536a925aef93175aa19ba2765671fdd5b4ada
data/CHANGELOG.md CHANGED
@@ -1,45 +1,57 @@
1
+ ## [v0.5.1](https://github.com/bryanp/llhttp/releases/tag/2025-03-11)
2
+
3
+ *released on 2025-03-11*
4
+
5
+ * `chg` [#32](https://github.com/bryanp/llhttp/pull/32) Remove Async::IO dependency ([ioquatix](https://github.com/ioquatix))
6
+
7
+ ## [v0.5.0](https://github.com/bryanp/llhttp/releases/tag/2023-03-29)
8
+
9
+ *released on 2023-03-29*
10
+
11
+ * `chg` [#27](https://github.com/bryanp/llhttp/pull/27) Update ffi to llhttp 8.1.0 ([bryanp](https://github.com/bryanp))
12
+
1
13
  ## v0.4.0
2
14
 
3
15
  *released on 2021-09-09*
4
16
 
5
- * `add` [#25](https://github.com/metabahn/llhttp/pull/25) Add support for resetting the parser ([bryanp](https://github.com/bryanp))
6
- * `chg` [#23](https://github.com/metabahn/llhttp/pull/23) Update ffi to llhttp 6.0.5 ([bryanp](https://github.com/bryanp))
17
+ * `add` [#25](https://github.com/bryanp/llhttp/pull/25) Add support for resetting the parser ([bryanp](https://github.com/bryanp))
18
+ * `chg` [#23](https://github.com/bryanp/llhttp/pull/23) Update ffi to llhttp 6.0.5 ([bryanp](https://github.com/bryanp))
7
19
 
8
- ## [v0.3.1](https://github.com/metabahn/llhttp/releases/tag/2021-06-25)
20
+ ## [v0.3.1](https://github.com/bryanp/llhttp/releases/tag/2021-06-25)
9
21
 
10
22
  *released on 2021-06-25*
11
23
 
12
- * `fix` [#22](https://github.com/metabahn/llhttp/pull/22) Fix call to ffi free ([bryanp](https://github.com/bryanp))
24
+ * `fix` [#22](https://github.com/bryanp/llhttp/pull/22) Fix call to ffi free ([bryanp](https://github.com/bryanp))
13
25
 
14
- ## [v0.3.0](https://github.com/metabahn/llhttp/releases/tag/2021-05-13)
26
+ ## [v0.3.0](https://github.com/bryanp/llhttp/releases/tag/2021-05-13)
15
27
 
16
28
  *released on 2021-05-13*
17
29
 
18
- * `chg` [#19](https://github.com/metabahn/llhttp/pull/19) Add back support for Ruby 2.5 in ffi ([bryanp](https://github.com/bryanp))
30
+ * `chg` [#19](https://github.com/bryanp/llhttp/pull/19) Add back support for Ruby 2.5 in ffi ([bryanp](https://github.com/bryanp))
19
31
 
20
- ## [v0.2.0](https://github.com/metabahn/llhttp/releases/tag/2021-05-06)
32
+ ## [v0.2.0](https://github.com/bryanp/llhttp/releases/tag/2021-05-06)
21
33
 
22
34
  *released on 2021-05-06*
23
35
 
24
- * `chg` [#17](https://github.com/metabahn/llhttp/pull/17) Update ffi to llhttp 6.0.1 ([bryanp](https://github.com/bryanp))
25
- * `chg` [#18](https://github.com/metabahn/llhttp/pull/18) Drop support for Ruby 2.5 ([bryanp](https://github.com/bryanp))
36
+ * `chg` [#17](https://github.com/bryanp/llhttp/pull/17) Update ffi to llhttp 6.0.1 ([bryanp](https://github.com/bryanp))
37
+ * `chg` [#18](https://github.com/bryanp/llhttp/pull/18) Drop support for Ruby 2.5 ([bryanp](https://github.com/bryanp))
26
38
 
27
- ## [v0.1.0](https://github.com/metabahn/llhttp/releases/tag/2021-04-06)
39
+ ## [v0.1.0](https://github.com/bryanp/llhttp/releases/tag/2021-04-06)
28
40
 
29
41
  *released on 2021-04-06*
30
42
 
31
- * `chg` [#14](https://github.com/metabahn/llhttp/pull/14) Update ffi to llhttp 5.1.0 ([bryanp](https://github.com/bryanp))
43
+ * `chg` [#14](https://github.com/bryanp/llhttp/pull/14) Update ffi to llhttp 5.1.0 ([bryanp](https://github.com/bryanp))
32
44
 
33
- ## [v0.0.1](https://github.com/metabahn/llhttp/releases/tag/2021-03-04)
45
+ ## [v0.0.1](https://github.com/bryanp/llhttp/releases/tag/2021-03-04)
34
46
 
35
47
  *released on 2021-03-04*
36
48
 
37
- * `fix` [#13](https://github.com/metabahn/llhttp/pull/13) Resolve an issue with the parser finalizer ([bryanp](https://github.com/bryanp))
49
+ * `fix` [#13](https://github.com/bryanp/llhttp/pull/13) Resolve an issue with the parser finalizer ([bryanp](https://github.com/bryanp))
38
50
 
39
- ## [v0.0.0](https://github.com/metabahn/llhttp/releases/tag/2021-03-03)
51
+ ## [v0.0.0](https://github.com/bryanp/llhttp/releases/tag/2021-03-03)
40
52
 
41
53
  *released on 2021-03-03*
42
54
 
43
- * `add` [#12](https://github.com/metabahn/llhttp/pull/12) Introduce llhttp-ffi for better compatibility ([bryanp](https://github.com/bryanp))
55
+ * `add` [#12](https://github.com/bryanp/llhttp/pull/12) Introduce llhttp-ffi for better compatibility ([bryanp](https://github.com/bryanp))
44
56
 
45
57
 
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>
@@ -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