llhttp 0.3.0 → 0.4.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: c3049572a0a42b0303696570fc91b7b657c716b014fc068ae549133b69aa6869
4
- data.tar.gz: 4122c65a1c18f2f3d07cadb2e5b95089d4fd142382e9cb9a47138eec6d7a6b20
3
+ metadata.gz: 3ee045e3bd145819a128933ba6e2bdc42493055e523afb6f96eb1b19e7efe5f9
4
+ data.tar.gz: 2143e6db1b7ff74e412b7839e1584380040d61f680596ed427b759638c1f837c
5
5
  SHA512:
6
- metadata.gz: 9ea99585b4658d2520a61cc00df75a3a298c8c7b8f850928da65ae49d2ce3501e25e2b3659140859617135f7af933ec4e20639ad49e81ef335019892b1a553ff
7
- data.tar.gz: 923b8dafbcd575d5fa27c722c52b4c7ae8a5be13044a589e045e8f4666913521539fbf808169e1beb9a6f345186a26bbc2285ea3643eb2197f1eaa3c2812a598
6
+ metadata.gz: 43be9c7c4858ae2e5862f0ae20f42a53f4bf2d526fb95bb879c108422f8cc5da1865e6a05037fc47eae4d4c0c7522046bbfc192e0204ee96478278cec623e3f7
7
+ data.tar.gz: '09049aaa065e7467a4a570b231273412eb3d66b9a3be342422eaf779e32b19a87e950a45e1b4720f50f179ce0c17f62295c67f86e10d360d5cc21a9d653f2a19'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## v0.4.0
2
+
3
+ *released on 2021-09-09*
4
+
5
+ * `add` [#25](https://github.com/metabahn/llhttp/pull/25) Add support for resetting the parser ([bryanp](https://github.com/bryanp))
6
+ * `chg` [#24](https://github.com/metabahn/llhttp/pull/24) Update mri to llhttp 6.0.5 ([bryanp](https://github.com/bryanp))
7
+
1
8
  ## v0.3.0
2
9
 
3
10
  *released on 2021-05-06*
data/README.md CHANGED
@@ -33,5 +33,5 @@ parser << "GET / HTTP/1.1\r\n\r\n"
33
33
 
34
34
  # Reset the parser for the next request:
35
35
  #
36
- parser.finish
36
+ parser.reset
37
37
  ```
data/ext/llhttp/api.c CHANGED
@@ -69,17 +69,23 @@ extern int wasm_on_url(llhttp_t* p, const char* at, size_t length);
69
69
  extern int wasm_on_status(llhttp_t* p, const char* at, size_t length);
70
70
  extern int wasm_on_header_field(llhttp_t* p, const char* at, size_t length);
71
71
  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);
72
+ extern int wasm_on_headers_complete(llhttp_t * p, int status_code,
73
+ uint8_t upgrade, int should_keep_alive);
73
74
  extern int wasm_on_body(llhttp_t* p, const char* at, size_t length);
74
75
  extern int wasm_on_message_complete(llhttp_t * p);
75
76
 
77
+ static int wasm_on_headers_complete_wrap(llhttp_t* p) {
78
+ return wasm_on_headers_complete(p, p->status_code, p->upgrade,
79
+ llhttp_should_keep_alive(p));
80
+ }
81
+
76
82
  const llhttp_settings_t wasm_settings = {
77
83
  wasm_on_message_begin,
78
84
  wasm_on_url,
79
85
  wasm_on_status,
80
86
  wasm_on_header_field,
81
87
  wasm_on_header_value,
82
- wasm_on_headers_complete,
88
+ wasm_on_headers_complete_wrap,
83
89
  wasm_on_body,
84
90
  wasm_on_message_complete,
85
91
  NULL,
data/ext/llhttp/llhttp.c CHANGED
@@ -1126,7 +1126,7 @@ static llparse_state_t llhttp__internal__run(
1126
1126
  case s_n_llhttp__internal__n_consume_content_length:
1127
1127
  s_n_llhttp__internal__n_consume_content_length: {
1128
1128
  size_t avail;
1129
- size_t need;
1129
+ uint64_t need;
1130
1130
 
1131
1131
  avail = endp - p;
1132
1132
  need = state->content_length;
@@ -1481,7 +1481,7 @@ static llparse_state_t llhttp__internal__run(
1481
1481
  case s_n_llhttp__internal__n_consume_content_length_1:
1482
1482
  s_n_llhttp__internal__n_consume_content_length_1: {
1483
1483
  size_t avail;
1484
- size_t need;
1484
+ uint64_t need;
1485
1485
 
1486
1486
  avail = endp - p;
1487
1487
  need = state->content_length;
@@ -8700,7 +8700,7 @@ static llparse_state_t llhttp__internal__run(
8700
8700
  case s_n_llhttp__internal__n_consume_content_length:
8701
8701
  s_n_llhttp__internal__n_consume_content_length: {
8702
8702
  size_t avail;
8703
- size_t need;
8703
+ uint64_t need;
8704
8704
 
8705
8705
  avail = endp - p;
8706
8706
  need = state->content_length;
@@ -9048,7 +9048,7 @@ static llparse_state_t llhttp__internal__run(
9048
9048
  case s_n_llhttp__internal__n_consume_content_length_1:
9049
9049
  s_n_llhttp__internal__n_consume_content_length_1: {
9050
9050
  size_t avail;
9051
- size_t need;
9051
+ uint64_t need;
9052
9052
 
9053
9053
  avail = endp - p;
9054
9054
  need = state->content_length;
data/ext/llhttp/llhttp.h CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
  #define LLHTTP_VERSION_MAJOR 6
28
28
  #define LLHTTP_VERSION_MINOR 0
29
- #define LLHTTP_VERSION_PATCH 1
29
+ #define LLHTTP_VERSION_PATCH 5
30
30
 
31
31
  #ifndef LLHTTP_STRICT_MODE
32
32
  # define LLHTTP_STRICT_MODE 0
@@ -154,6 +154,18 @@ VALUE rb_llhttp_finish(VALUE self) {
154
154
  return Qtrue;
155
155
  }
156
156
 
157
+ VALUE rb_llhttp_reset(VALUE self) {
158
+ llhttp_t *parser;
159
+
160
+ Data_Get_Struct(self, llhttp_t, parser);
161
+
162
+ llhttp_settings_t *settings = parser->settings;
163
+
164
+ llhttp_reset(parser);
165
+
166
+ return Qtrue;
167
+ }
168
+
157
169
  VALUE rb_llhttp_content_length(VALUE self) {
158
170
  llhttp_t *parser;
159
171
 
@@ -301,6 +313,7 @@ void Init_llhttp_ext(void) {
301
313
  rb_define_method(cParser, "<<", rb_llhttp_parse, 1);
302
314
  rb_define_method(cParser, "parse", rb_llhttp_parse, 1);
303
315
  rb_define_method(cParser, "finish", rb_llhttp_finish, 0);
316
+ rb_define_method(cParser, "reset", rb_llhttp_reset, 0);
304
317
 
305
318
  rb_define_method(cParser, "content_length", rb_llhttp_content_length, 0);
306
319
  rb_define_method(cParser, "method_name", rb_llhttp_method_name, 0);
data/lib/llhttp/parser.rb CHANGED
@@ -30,6 +30,10 @@ module LLHttp
30
30
  #
31
31
  # Call `LLHttp::Parser#finish` when processing is complete for the current request or response.
32
32
  #
33
+ # Resetting
34
+ #
35
+ # Call `LLHttp::Parser#reset` to reset the parser for the next request or response.
36
+ #
33
37
  class Parser
34
38
  LLHTTP_TYPES = {both: 0, request: 1, response: 2}.freeze
35
39
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LLHttp
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
 
6
6
  # [public] LLHttp's current version.
7
7
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llhttp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-07 00:00:00.000000000 Z
11
+ date: 2021-09-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby bindings for llhttp.
14
14
  email: bryan@metabahn.com