llhttp-ffi 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6af451609178568c6487f75fcece2bf8915e0bec6fd51a44761598382afa5de
4
- data.tar.gz: 037b38718ded224ec48808f183b1bf9a5e8f65949eaf0fd64379657233521bd1
3
+ metadata.gz: 9720c041b7640bb1d125d8b62c758c78127a7d665c93f1d564df6b2fbaac0581
4
+ data.tar.gz: 2fde51f637fd54f90888e944ee29257aee370e7f3353c2edb4040a28539c5018
5
5
  SHA512:
6
- metadata.gz: 2947c990fdb5a4909d2c631e417bff9e9003b04d0f7fed674d01d7328f75dab2766d1ec4f3aa591267f94c3cf03be352d6aaebe176a49558703675ba3cc087b7
7
- data.tar.gz: 5feb106a0e5f6e92cd1f63b506bc84af6add70565cc1f603a4cdb55ae7af2cbc71bf4f1a68df02b1238bdf25bf08e58255cbc010141817081986578d5b9d1645
6
+ metadata.gz: 7048b50742f8e1cb52d62906f57b5d38f5af4835ee5fe8e39c3d188409329f802423a9f278f2bbdaea59102a7313956f2ff7037158ee29aac2b29fb6b56311df
7
+ data.tar.gz: 885c7f34f7917b0bf4da8116159045f3821c010467a84e9485fd10c3418d1972e1a88127a03c3e2900a5ad9017e014997b0773f5987614ec5621d8023b64906c
data/CHANGELOG.md CHANGED
@@ -1,45 +1,49 @@
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
+
1
7
  ## v0.4.0
2
8
 
3
9
  *released on 2021-09-09*
4
10
 
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))
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))
7
13
 
8
- ## [v0.3.1](https://github.com/metabahn/llhttp/releases/tag/2021-06-25)
14
+ ## [v0.3.1](https://github.com/bryanp/llhttp/releases/tag/2021-06-25)
9
15
 
10
16
  *released on 2021-06-25*
11
17
 
12
- * `fix` [#22](https://github.com/metabahn/llhttp/pull/22) Fix call to ffi free ([bryanp](https://github.com/bryanp))
18
+ * `fix` [#22](https://github.com/bryanp/llhttp/pull/22) Fix call to ffi free ([bryanp](https://github.com/bryanp))
13
19
 
14
- ## [v0.3.0](https://github.com/metabahn/llhttp/releases/tag/2021-05-13)
20
+ ## [v0.3.0](https://github.com/bryanp/llhttp/releases/tag/2021-05-13)
15
21
 
16
22
  *released on 2021-05-13*
17
23
 
18
- * `chg` [#19](https://github.com/metabahn/llhttp/pull/19) Add back support for Ruby 2.5 in ffi ([bryanp](https://github.com/bryanp))
24
+ * `chg` [#19](https://github.com/bryanp/llhttp/pull/19) Add back support for Ruby 2.5 in ffi ([bryanp](https://github.com/bryanp))
19
25
 
20
- ## [v0.2.0](https://github.com/metabahn/llhttp/releases/tag/2021-05-06)
26
+ ## [v0.2.0](https://github.com/bryanp/llhttp/releases/tag/2021-05-06)
21
27
 
22
28
  *released on 2021-05-06*
23
29
 
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))
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))
26
32
 
27
- ## [v0.1.0](https://github.com/metabahn/llhttp/releases/tag/2021-04-06)
33
+ ## [v0.1.0](https://github.com/bryanp/llhttp/releases/tag/2021-04-06)
28
34
 
29
35
  *released on 2021-04-06*
30
36
 
31
- * `chg` [#14](https://github.com/metabahn/llhttp/pull/14) Update ffi to llhttp 5.1.0 ([bryanp](https://github.com/bryanp))
37
+ * `chg` [#14](https://github.com/bryanp/llhttp/pull/14) Update ffi to llhttp 5.1.0 ([bryanp](https://github.com/bryanp))
32
38
 
33
- ## [v0.0.1](https://github.com/metabahn/llhttp/releases/tag/2021-03-04)
39
+ ## [v0.0.1](https://github.com/bryanp/llhttp/releases/tag/2021-03-04)
34
40
 
35
41
  *released on 2021-03-04*
36
42
 
37
- * `fix` [#13](https://github.com/metabahn/llhttp/pull/13) Resolve an issue with the parser finalizer ([bryanp](https://github.com/bryanp))
43
+ * `fix` [#13](https://github.com/bryanp/llhttp/pull/13) Resolve an issue with the parser finalizer ([bryanp](https://github.com/bryanp))
38
44
 
39
- ## [v0.0.0](https://github.com/metabahn/llhttp/releases/tag/2021-03-03)
45
+ ## [v0.0.0](https://github.com/bryanp/llhttp/releases/tag/2021-03-03)
40
46
 
41
47
  *released on 2021-03-03*
42
48
 
43
- * `add` [#12](https://github.com/metabahn/llhttp/pull/12) Introduce llhttp-ffi for better compatibility ([bryanp](https://github.com/bryanp))
44
-
45
-
49
+ * `add` [#12](https://github.com/bryanp/llhttp/pull/12) Introduce llhttp-ffi for better compatibility ([bryanp](https://github.com/bryanp))
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