llhttp 0.5.0 → 0.6.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: 1e15a0ef9a22a029ad2b29b6a173fa5eb9bc7cee0a7ec819bf0cb9be068e106b
4
- data.tar.gz: 50b10fdfeaa7a752f1ce50bcb3f4ebb4e7b0eea75af978acd2c5fa467eed345a
3
+ metadata.gz: 5042607c857885f7e9e276ef979465caf2eea262e766d4c28938887d8933f173
4
+ data.tar.gz: 00531eed2651d3f9f9800d47252d6998c9d1e4d9f9a577a8fe8f6b04f92874be
5
5
  SHA512:
6
- metadata.gz: 38088c14fd79320cbd278dc305259636e1bed27358061eb94d2f99a859c0b0ce2d72976832b5026c861f98c57daf2782c8a00d1faf91d9898c9674e847a76455
7
- data.tar.gz: 4e1be65888e3a2f9593c4208ae67c2cf9792d4779689755df882851817637e7b111a8e08caee4eb95509f38ced4119a48898744351f376ce941eb7f617ab03ef
6
+ metadata.gz: cb65e98b9bb0f61bbd86949136fdbf0be367f28e0698169a848244d3ba88e521b71cbe7c845f4afddd8606d18b8363675cd4818bb9e6ca4184554f2ad85997fa
7
+ data.tar.gz: d6f1ef8087034637698d20bd0c547382104ab964850bef893f64dc9ed269692955d6fbb229cce9e066253e663f2ffb8223ab8650e2e17e9853c86490ac7e566d
data/CHANGELOG.md CHANGED
@@ -1,57 +1,61 @@
1
- ## [v0.5.0](https://github.com/metabahn/llhttp/releases/tag/2021-09-21)
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)
2
8
 
3
9
  *released on 2021-09-21*
4
10
 
5
- * `chg` [#26](https://github.com/metabahn/llhttp/pull/26) Refactor parser data to include all values ([bryanp](https://github.com/bryanp))
11
+ * `chg` [#26](https://github.com/bryanp/llhttp/pull/26) Refactor parser data to include all values ([bryanp](https://github.com/bryanp))
6
12
 
7
- ## [v0.4.0](https://github.com/metabahn/llhttp/releases/tag/2021-09-09)
13
+ ## [v0.4.0](https://github.com/bryanp/llhttp/releases/tag/2021-09-09)
8
14
 
9
15
  *released on 2021-09-09*
10
16
 
11
- * `add` [#25](https://github.com/metabahn/llhttp/pull/25) Add support for resetting the parser ([bryanp](https://github.com/bryanp))
12
- * `chg` [#24](https://github.com/metabahn/llhttp/pull/24) Update mri 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` [#24](https://github.com/bryanp/llhttp/pull/24) Update mri to llhttp 6.0.5 ([bryanp](https://github.com/bryanp))
13
19
 
14
- ## [v0.3.0](https://github.com/metabahn/llhttp/releases/tag/2021-05-06)
20
+ ## [v0.3.0](https://github.com/bryanp/llhttp/releases/tag/2021-05-06)
15
21
 
16
22
  *released on 2021-05-06*
17
23
 
18
- * `chg` [#16](https://github.com/metabahn/llhttp/pull/16) Update mri to llhttp 6.0.1 ([bryanp](https://github.com/bryanp))
19
- * `chg` [#18](https://github.com/metabahn/llhttp/pull/18) Drop support for Ruby 2.5 ([bryanp](https://github.com/bryanp))
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))
20
26
 
21
- ## [v0.2.0](https://github.com/metabahn/llhttp/releases/tag/2021-04-06)
27
+ ## [v0.2.0](https://github.com/bryanp/llhttp/releases/tag/2021-04-06)
22
28
 
23
29
  *released on 2021-04-06*
24
30
 
25
- * `chg` [#15](https://github.com/metabahn/llhttp/pull/15) Update mri to llhttp 5.1.0 ([bryanp](https://github.com/bryanp))
31
+ * `chg` [#15](https://github.com/bryanp/llhttp/pull/15) Update mri to llhttp 5.1.0 ([bryanp](https://github.com/bryanp))
26
32
 
27
- ## [v0.1.0](https://github.com/metabahn/llhttp/releases/tag/2021-03-03)
33
+ ## [v0.1.0](https://github.com/bryanp/llhttp/releases/tag/2021-03-03)
28
34
 
29
35
  *released on 2021-03-03*
30
36
 
31
- * `chg` [#11](https://github.com/metabahn/llhttp/pull/11) Rename Parser#method to Parser#method_name ([bryanp](https://github.com/bryanp))
32
- * `chg` [#10](https://github.com/metabahn/llhttp/pull/10) Only setup callbacks if they are defined on the delegate ([bryanp](https://github.com/bryanp))
33
- * `chg` [#9](https://github.com/metabahn/llhttp/pull/9) Update llhttp to 4.0.0 ([bryanp](https://github.com/bryanp))
34
- * `add` [#2](https://github.com/metabahn/llhttp/pull/2) Support introspection of http major/minor version ([midnight-wonderer](https://github.com/midnight-wonderer))
35
- * `add` [#8](https://github.com/metabahn/llhttp/pull/8) Support new *_complete callbacks ([bryanp](https://github.com/bryanp))
36
- * `chg` [#7](https://github.com/metabahn/llhttp/pull/7) Return an error status from the appropriate callbacks ([bryanp](https://github.com/bryanp))
37
- * `chg` [#6](https://github.com/metabahn/llhttp/pull/6) Update llhttp to 3.0.1 ([bryanp](https://github.com/bryanp))
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))
38
44
 
39
- ## [v0.0.3](https://github.com/metabahn/llhttp/releases/tag/v0.0.3)
45
+ ## [v0.0.3](https://github.com/bryanp/llhttp/releases/tag/v0.0.3)
40
46
 
41
47
  *released on 2020-12-30*
42
48
 
43
- * `fix` [#5](https://github.com/metabahn/llhttp/pull/5) Build the extension correctly ([bryanp](https://github.com/bryanp))
49
+ * `fix` [#5](https://github.com/bryanp/llhttp/pull/5) Build the extension correctly ([bryanp](https://github.com/bryanp))
44
50
 
45
- ## [v0.0.2](https://github.com/metabahn/llhttp/releases/tag/v0.0.2)
51
+ ## [v0.0.2](https://github.com/bryanp/llhttp/releases/tag/v0.0.2)
46
52
 
47
53
  *released on 2020-10-11*
48
54
 
49
55
  * `fix` Correctly free parser settings when freeing the parser.
50
56
 
51
- ## [v0.0.1](https://github.com/metabahn/llhttp/releases/tag/v0.0.1)
57
+ ## [v0.0.1](https://github.com/bryanp/llhttp/releases/tag/v0.0.1)
52
58
 
53
59
  *released on 2020-10-11*
54
60
 
55
61
  * Initial release.
56
-
57
-
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