llhttp-ffi 0.3.1 → 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: ec9725ef7398a6548859c7aab1dfb17a3bfc1aa1db2824d6f917a44528df130a
4
- data.tar.gz: 790e594a54a2c0b5ffac84c3f88ee83d8190b2f159b2e535e302c13b92211dfd
3
+ metadata.gz: c6af451609178568c6487f75fcece2bf8915e0bec6fd51a44761598382afa5de
4
+ data.tar.gz: 037b38718ded224ec48808f183b1bf9a5e8f65949eaf0fd64379657233521bd1
5
5
  SHA512:
6
- metadata.gz: dbefe79c2c76d2bed5aab900924f1ae7d45f9a7b5a21b19f0773e0e594c3123c7aefbad04af2418bf85d3f5d9e1a1c200b0cc37e6b3f74a4224dfbd84ef771a0
7
- data.tar.gz: 655d99b69334d5b9471aab8a43142d021e556d20813805b95508f556bd6f990bbaa8d7a634b293435978971ae8c66233def9ba49be892bf25d9d9b50a8c90f01
6
+ metadata.gz: 2947c990fdb5a4909d2c631e417bff9e9003b04d0f7fed674d01d7328f75dab2766d1ec4f3aa591267f94c3cf03be352d6aaebe176a49558703675ba3cc087b7
7
+ data.tar.gz: 5feb106a0e5f6e92cd1f63b506bc84af6add70565cc1f603a4cdb55ae7af2cbc71bf4f1a68df02b1238bdf25bf08e58255cbc010141817081986578d5b9d1645
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` [#23](https://github.com/metabahn/llhttp/pull/23) Update ffi to llhttp 6.0.5 ([bryanp](https://github.com/bryanp))
7
+
1
8
  ## [v0.3.1](https://github.com/metabahn/llhttp/releases/tag/2021-06-25)
2
9
 
3
10
  *released on 2021-06-25*
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
data/lib/llhttp/parser.rb CHANGED
@@ -117,12 +117,18 @@ module LLHttp
117
117
  LLHttp.llhttp_should_keep_alive(@pointer) == 1
118
118
  end
119
119
 
120
- # [public] Get ready to parse the next request.
120
+ # [public] Tells the parser we are finished.
121
121
  #
122
122
  def finish
123
123
  LLHttp.llhttp_finish(@pointer)
124
124
  end
125
125
 
126
+ # [public] Get ready to parse the next request/response.
127
+ #
128
+ def reset
129
+ LLHttp.llhttp_reset(@pointer)
130
+ end
131
+
126
132
  CALLBACKS.each do |callback|
127
133
  class_eval(
128
134
  <<~RB, __FILE__, __LINE__ + 1
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LLHttp
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
 
6
6
  # [public] LLHttp's current version.
7
7
  #
data/lib/llhttp.rb CHANGED
@@ -45,4 +45,5 @@ module LLHttp
45
45
  attach_function :llhttp_get_error_reason, [:pointer], :string
46
46
  attach_function :llhttp_should_keep_alive, [:pointer], :int
47
47
  attach_function :llhttp_finish, [:pointer], :int
48
+ attach_function :llhttp_reset, [:pointer], :void
48
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llhttp-ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
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-06-26 00:00:00.000000000 Z
11
+ date: 2021-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi-compiler