llhttp 0.6.0 → 0.6.2

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: 5042607c857885f7e9e276ef979465caf2eea262e766d4c28938887d8933f173
4
- data.tar.gz: 00531eed2651d3f9f9800d47252d6998c9d1e4d9f9a577a8fe8f6b04f92874be
3
+ metadata.gz: 587b610dc8133b3cad26a796f5b5b8f233f7a22f412f311622e56dc4e104f22d
4
+ data.tar.gz: e274ee30502f1a585e0957973f9f8c904d63c354e61a9604aec3efa918ed461e
5
5
  SHA512:
6
- metadata.gz: cb65e98b9bb0f61bbd86949136fdbf0be367f28e0698169a848244d3ba88e521b71cbe7c845f4afddd8606d18b8363675cd4818bb9e6ca4184554f2ad85997fa
7
- data.tar.gz: d6f1ef8087034637698d20bd0c547382104ab964850bef893f64dc9ed269692955d6fbb229cce9e066253e663f2ffb8223ab8650e2e17e9853c86490ac7e566d
6
+ metadata.gz: 3976724436b35bd5bc09fd08d4e8631673da1cb69f771328b219ea0a61cf19a9ba5f406bbfdd46dc213fc808a9b4dc20a7fa70d34f5e602118919b234dcdfd94
7
+ data.tar.gz: ddca2e5d0df353f438acfb4091a5d811e4ce05725bdcc159174cfa7b27cce6b8437d2008423876e5aca84e0f756e39c6c88bb9e559180f738c7569ea238c304c
data/CHANGELOG.md CHANGED
@@ -1,8 +1,15 @@
1
- ## [v0.6.0](https://github.com/bryanp/llhttp/releases/tag/2023-03-29)
1
+ ## [v0.6.2](https://github.com/bryanp/llhttp/releases/tag/2026-06-28)
2
2
 
3
- *released on 2023-03-29*
3
+ *released on 2026-06-28*
4
4
 
5
- * `chg` [#28](https://github.com/bryanp/llhttp/pull/28) Update mri to llhttp 8.1.0 ([bryanp](https://github.com/bryanp))
5
+ * `chg` [#37](https://github.com/bryanp/llhttp/pull/37) Use the typed data API for Ruby 4 compatibility ([nobu](https://github.com/nobu))
6
+ * `chg` [#35](https://github.com/bryanp/llhttp/pull/35) Declare functions as Ractor-safe ([jhawthorn](https://github.com/jhawthorn))
7
+
8
+ ## [v0.6.1](https://github.com/bryanp/llhttp/releases/tag/2025-03-11)
9
+
10
+ *released on 2025-03-11*
11
+
12
+ * `chg` [#32](https://github.com/bryanp/llhttp/pull/32) Remove Async::IO dependency ([ioquatix](https://github.com/ioquatix))
6
13
 
7
14
  ## [v0.5.0](https://github.com/bryanp/llhttp/releases/tag/2021-09-21)
8
15
 
@@ -59,3 +66,5 @@
59
66
  *released on 2020-10-11*
60
67
 
61
68
  * Initial release.
69
+
70
+
@@ -3,4 +3,8 @@
3
3
  require "mkmf"
4
4
 
5
5
  dir_config("llhttp_ext")
6
+
7
+ # Check for Ractor support
8
+ have_func("rb_ext_ractor_safe", "ruby.h")
9
+
6
10
  create_makefile("llhttp_ext")
@@ -28,7 +28,8 @@ typedef struct {
28
28
  ID on_header_value_complete;
29
29
  } rb_llhttp_parser_data;
30
30
 
31
- static void rb_llhttp_free(llhttp_t *parser) {
31
+ static void rb_llhttp_free(void *data) {
32
+ llhttp_t *parser = data;
32
33
  rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
33
34
 
34
35
  // If `parserData` is not `0`, it (and settings) were initialized.
@@ -41,21 +42,50 @@ static void rb_llhttp_free(llhttp_t *parser) {
41
42
  free(parser);
42
43
  }
43
44
 
45
+ #ifdef TypedData_Make_Struct
46
+ static size_t rb_llhttp_memsize(const void *data) {
47
+ return data ? sizeof(llhttp_t) : 0;
48
+ }
49
+
50
+ static const rb_data_type_t rb_llhttp_type = {
51
+ "LLHttp::Parser",
52
+ {0, rb_llhttp_free, rb_llhttp_memsize,},
53
+ 0, 0, 0,
54
+ };
55
+ #endif
56
+
57
+ static llhttp_t *rb_llhttp_get(VALUE self) {
58
+ llhttp_t *parser;
59
+
60
+ #ifdef TypedData_Make_Struct
61
+ TypedData_Get_Struct(self, llhttp_t, &rb_llhttp_type, parser);
62
+ #else
63
+ Data_Get_Struct(self, llhttp_t, parser);
64
+ #endif
65
+
66
+ return parser;
67
+ }
68
+
44
69
  VALUE rb_llhttp_allocate(VALUE klass) {
45
- llhttp_t *parser = (llhttp_t *)malloc(sizeof(llhttp_t));
70
+ llhttp_t *parser;
71
+ #ifdef TypedData_Make_Struct
72
+ VALUE self = TypedData_Make_Struct(klass, llhttp_t, &rb_llhttp_type, parser);
73
+ #else
74
+ VALUE self = Data_Make_Struct(klass, llhttp_t, 0, rb_llhttp_free, parser);
75
+ #endif
46
76
 
47
77
  // Set data to false so we know when the parser has been initialized.
48
78
  //
49
79
  parser->data = 0;
50
80
 
51
- return Data_Wrap_Struct(klass, 0, rb_llhttp_free, parser);
81
+ return self;
52
82
  }
53
83
 
54
84
  VALUE rb_llhttp_callback_call(VALUE delegate, ID method) {
55
85
  return rb_funcall(delegate, method, 0);
56
86
  }
57
87
 
58
- void rb_llhttp_data_callback_call(VALUE delegate, ID method, char *data, size_t length) {
88
+ void rb_llhttp_data_callback_call(VALUE delegate, ID method, const char *data, size_t length) {
59
89
  rb_funcall(delegate, method, 1, rb_str_new(data, length));
60
90
  }
61
91
 
@@ -83,7 +113,7 @@ int rb_llhttp_on_chunk_header(llhttp_t *parser) {
83
113
  return NUM2INT(rb_llhttp_callback_call(parserData->delegate, parserData->on_chunk_header));
84
114
  }
85
115
 
86
- int rb_llhttp_on_url(llhttp_t *parser, char *data, size_t length) {
116
+ int rb_llhttp_on_url(llhttp_t *parser, const char *data, size_t length) {
87
117
  rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
88
118
 
89
119
  rb_llhttp_data_callback_call(parserData->delegate, parserData->on_url, data, length);
@@ -91,7 +121,7 @@ int rb_llhttp_on_url(llhttp_t *parser, char *data, size_t length) {
91
121
  return 0;
92
122
  }
93
123
 
94
- int rb_llhttp_on_status(llhttp_t *parser, char *data, size_t length) {
124
+ int rb_llhttp_on_status(llhttp_t *parser, const char *data, size_t length) {
95
125
  rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
96
126
 
97
127
  rb_llhttp_data_callback_call(parserData->delegate, parserData->on_status, data, length);
@@ -99,7 +129,7 @@ int rb_llhttp_on_status(llhttp_t *parser, char *data, size_t length) {
99
129
  return 0;
100
130
  }
101
131
 
102
- int rb_llhttp_on_header_field(llhttp_t *parser, char *data, size_t length) {
132
+ int rb_llhttp_on_header_field(llhttp_t *parser, const char *data, size_t length) {
103
133
  rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
104
134
 
105
135
  rb_llhttp_data_callback_call(parserData->delegate, parserData->on_header_field, data, length);
@@ -107,7 +137,7 @@ int rb_llhttp_on_header_field(llhttp_t *parser, char *data, size_t length) {
107
137
  return 0;
108
138
  }
109
139
 
110
- int rb_llhttp_on_header_value(llhttp_t *parser, char *data, size_t length) {
140
+ int rb_llhttp_on_header_value(llhttp_t *parser, const char *data, size_t length) {
111
141
  rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
112
142
 
113
143
  rb_llhttp_data_callback_call(parserData->delegate, parserData->on_header_value, data, length);
@@ -115,7 +145,7 @@ int rb_llhttp_on_header_value(llhttp_t *parser, char *data, size_t length) {
115
145
  return 0;
116
146
  }
117
147
 
118
- int rb_llhttp_on_body(llhttp_t *parser, char *data, size_t length) {
148
+ int rb_llhttp_on_body(llhttp_t *parser, const char *data, size_t length) {
119
149
  rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
120
150
 
121
151
  rb_llhttp_data_callback_call(parserData->delegate, parserData->on_body, data, length);
@@ -166,7 +196,7 @@ int rb_llhttp_on_header_value_complete(llhttp_t *parser) {
166
196
  VALUE rb_llhttp_parse(VALUE self, VALUE data) {
167
197
  llhttp_t *parser;
168
198
 
169
- Data_Get_Struct(self, llhttp_t, parser);
199
+ parser = rb_llhttp_get(self);
170
200
 
171
201
  enum llhttp_errno err = llhttp_execute(parser, RSTRING_PTR(data), RSTRING_LEN(data));
172
202
 
@@ -180,7 +210,7 @@ VALUE rb_llhttp_parse(VALUE self, VALUE data) {
180
210
  VALUE rb_llhttp_finish(VALUE self) {
181
211
  llhttp_t *parser;
182
212
 
183
- Data_Get_Struct(self, llhttp_t, parser);
213
+ parser = rb_llhttp_get(self);
184
214
 
185
215
  enum llhttp_errno err = llhttp_finish(parser);
186
216
 
@@ -194,7 +224,7 @@ VALUE rb_llhttp_finish(VALUE self) {
194
224
  VALUE rb_llhttp_reset(VALUE self) {
195
225
  llhttp_t *parser;
196
226
 
197
- Data_Get_Struct(self, llhttp_t, parser);
227
+ parser = rb_llhttp_get(self);
198
228
 
199
229
  llhttp_reset(parser);
200
230
 
@@ -204,7 +234,7 @@ VALUE rb_llhttp_reset(VALUE self) {
204
234
  VALUE rb_llhttp_content_length(VALUE self) {
205
235
  llhttp_t *parser;
206
236
 
207
- Data_Get_Struct(self, llhttp_t, parser);
237
+ parser = rb_llhttp_get(self);
208
238
 
209
239
  return ULL2NUM(parser->content_length);
210
240
  }
@@ -212,7 +242,7 @@ VALUE rb_llhttp_content_length(VALUE self) {
212
242
  VALUE rb_llhttp_method_name(VALUE self) {
213
243
  llhttp_t *parser;
214
244
 
215
- Data_Get_Struct(self, llhttp_t, parser);
245
+ parser = rb_llhttp_get(self);
216
246
 
217
247
  return rb_str_new_cstr(llhttp_method_name(parser->method));
218
248
  }
@@ -220,7 +250,7 @@ VALUE rb_llhttp_method_name(VALUE self) {
220
250
  VALUE rb_llhttp_status_code(VALUE self) {
221
251
  llhttp_t *parser;
222
252
 
223
- Data_Get_Struct(self, llhttp_t, parser);
253
+ parser = rb_llhttp_get(self);
224
254
 
225
255
  return UINT2NUM(parser->status_code);
226
256
  }
@@ -228,7 +258,7 @@ VALUE rb_llhttp_status_code(VALUE self) {
228
258
  VALUE rb_llhttp_http_major(VALUE self) {
229
259
  llhttp_t *parser;
230
260
 
231
- Data_Get_Struct(self, llhttp_t, parser);
261
+ parser = rb_llhttp_get(self);
232
262
 
233
263
  return UINT2NUM(parser->http_major);
234
264
  }
@@ -236,7 +266,7 @@ VALUE rb_llhttp_http_major(VALUE self) {
236
266
  VALUE rb_llhttp_http_minor(VALUE self) {
237
267
  llhttp_t *parser;
238
268
 
239
- Data_Get_Struct(self, llhttp_t, parser);
269
+ parser = rb_llhttp_get(self);
240
270
 
241
271
  return UINT2NUM(parser->http_minor);
242
272
  }
@@ -244,7 +274,7 @@ VALUE rb_llhttp_http_minor(VALUE self) {
244
274
  VALUE rb_llhttp_keep_alive(VALUE self) {
245
275
  llhttp_t *parser;
246
276
 
247
- Data_Get_Struct(self, llhttp_t, parser);
277
+ parser = rb_llhttp_get(self);
248
278
 
249
279
  int ret = llhttp_should_keep_alive(parser);
250
280
 
@@ -254,7 +284,7 @@ VALUE rb_llhttp_keep_alive(VALUE self) {
254
284
  static VALUE rb_llhttp_init(VALUE self, VALUE type) {
255
285
  llhttp_t *parser;
256
286
 
257
- Data_Get_Struct(self, llhttp_t, parser);
287
+ parser = rb_llhttp_get(self);
258
288
 
259
289
  llhttp_settings_t *settings = (llhttp_settings_t *)malloc(sizeof(llhttp_settings_t));
260
290
  llhttp_settings_init(settings);
@@ -294,23 +324,23 @@ static VALUE rb_llhttp_init(VALUE self, VALUE type) {
294
324
  }
295
325
 
296
326
  if (rb_respond_to(parserData->delegate, parserData->on_url)) {
297
- settings->on_url = (llhttp_data_cb)rb_llhttp_on_url;
327
+ settings->on_url = rb_llhttp_on_url;
298
328
  }
299
329
 
300
330
  if (rb_respond_to(parserData->delegate, parserData->on_status)) {
301
- settings->on_status = (llhttp_data_cb)rb_llhttp_on_status;
331
+ settings->on_status = rb_llhttp_on_status;
302
332
  }
303
333
 
304
334
  if (rb_respond_to(parserData->delegate, parserData->on_header_field)) {
305
- settings->on_header_field = (llhttp_data_cb)rb_llhttp_on_header_field;
335
+ settings->on_header_field = rb_llhttp_on_header_field;
306
336
  }
307
337
 
308
338
  if (rb_respond_to(parserData->delegate, parserData->on_header_value)) {
309
- settings->on_header_value = (llhttp_data_cb)rb_llhttp_on_header_value;
339
+ settings->on_header_value = rb_llhttp_on_header_value;
310
340
  }
311
341
 
312
342
  if (rb_respond_to(parserData->delegate, parserData->on_body)) {
313
- settings->on_body = (llhttp_data_cb)rb_llhttp_on_body;
343
+ settings->on_body = rb_llhttp_on_body;
314
344
  }
315
345
 
316
346
  if (rb_respond_to(parserData->delegate, parserData->on_chunk_complete)) {
@@ -341,6 +371,10 @@ static VALUE rb_llhttp_init(VALUE self, VALUE type) {
341
371
  }
342
372
 
343
373
  void Init_llhttp_ext(void) {
374
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
375
+ rb_ext_ractor_safe(true);
376
+ #endif
377
+
344
378
  mLLHttp = rb_const_get(rb_cObject, rb_intern("LLHttp"));
345
379
  cParser = rb_const_get(mLLHttp, rb_intern("Parser"));
346
380
  eError = rb_const_get(mLLHttp, rb_intern("Error"));
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LLHttp
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.2"
5
5
 
6
6
  # [public] LLHttp's current version.
7
7
  #
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llhttp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-03-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Ruby bindings for llhttp.
14
13
  email: bryan@bryanp.org
@@ -35,7 +34,6 @@ homepage: https://github.com/bryanp/llhttp/
35
34
  licenses:
36
35
  - MPL-2.0
37
36
  metadata: {}
38
- post_install_message:
39
37
  rdoc_options: []
40
38
  require_paths:
41
39
  - lib
@@ -50,8 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
48
  - !ruby/object:Gem::Version
51
49
  version: '0'
52
50
  requirements: []
53
- rubygems_version: 3.4.9
54
- signing_key:
51
+ rubygems_version: 4.0.6
55
52
  specification_version: 4
56
53
  summary: Ruby bindings for llhttp.
57
54
  test_files: []