llhttp 0.6.1 → 0.6.3
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 +4 -4
- data/CHANGELOG.md +15 -0
- data/ext/llhttp/extconf.rb +4 -0
- data/ext/llhttp/llhttp_ext.c +72 -24
- data/lib/llhttp/parser.rb +1 -1
- data/lib/llhttp/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: deed0031ebf36b3f0243f832465d3966c1ebe7237363ac1f5f26634871572739
|
|
4
|
+
data.tar.gz: 9df545c4393d3f0b04fa0d000584c1f002ffd682a586942a5e98a9aae85683b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51f44b0a48898cc75ba681850b0ed3b63392a24b0041fc6b509eabe2b8f4eb477ef6a7b4904b7a8410e41b25cddc4711b7719a8d35cf261a782bb3d8c222496b
|
|
7
|
+
data.tar.gz: 3f4df743b18910cfcab045576710a2d4f202e4017863da11b7bbba4c82f831f65eeeb16ff06b43683bd37122a67927d4da009b6ec9b86d8725b23ad0ce08f2c1
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [v0.6.3](https://github.com/bryanp/llhttp/releases/tag/2026-12-05)
|
|
2
|
+
|
|
3
|
+
*released on 2026-12-05*
|
|
4
|
+
|
|
5
|
+
* `fix` [#46](https://github.com/bryanp/llhttp/pull/46) Load the native extension from the load path ([Annih](https://github.com/Annih))
|
|
6
|
+
* `fix` [#45](https://github.com/bryanp/llhttp/pull/45) Raise TypeError when parsing data that is not a string ([bryanp](https://github.com/bryanp))
|
|
7
|
+
* `fix` [#40](https://github.com/bryanp/llhttp/pull/40) Mark the delegate so the parser survives GC compaction ([benubois](https://github.com/benubois))
|
|
8
|
+
|
|
9
|
+
## [v0.6.2](https://github.com/bryanp/llhttp/releases/tag/2026-06-28)
|
|
10
|
+
|
|
11
|
+
*released on 2026-06-28*
|
|
12
|
+
|
|
13
|
+
* `chg` [#37](https://github.com/bryanp/llhttp/pull/37) Use the typed data API for Ruby 4 compatibility ([nobu](https://github.com/nobu))
|
|
14
|
+
* `chg` [#35](https://github.com/bryanp/llhttp/pull/35) Declare functions as Ractor-safe ([jhawthorn](https://github.com/jhawthorn))
|
|
15
|
+
|
|
1
16
|
## [v0.6.1](https://github.com/bryanp/llhttp/releases/tag/2025-03-11)
|
|
2
17
|
|
|
3
18
|
*released on 2025-03-11*
|
data/ext/llhttp/extconf.rb
CHANGED
data/ext/llhttp/llhttp_ext.c
CHANGED
|
@@ -28,7 +28,20 @@ typedef struct {
|
|
|
28
28
|
ID on_header_value_complete;
|
|
29
29
|
} rb_llhttp_parser_data;
|
|
30
30
|
|
|
31
|
-
static void
|
|
31
|
+
static void rb_llhttp_mark(void *data) {
|
|
32
|
+
llhttp_t *parser = data;
|
|
33
|
+
rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
|
|
34
|
+
|
|
35
|
+
// If `parserData` is not `0`, mark the delegate so it is pinned. The delegate
|
|
36
|
+
// is cached in `parserData`, which would be left dangling if compaction moved it.
|
|
37
|
+
//
|
|
38
|
+
if (parserData != 0) {
|
|
39
|
+
rb_gc_mark(parserData->delegate);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static void rb_llhttp_free(void *data) {
|
|
44
|
+
llhttp_t *parser = data;
|
|
32
45
|
rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
|
|
33
46
|
|
|
34
47
|
// If `parserData` is not `0`, it (and settings) were initialized.
|
|
@@ -41,21 +54,50 @@ static void rb_llhttp_free(llhttp_t *parser) {
|
|
|
41
54
|
free(parser);
|
|
42
55
|
}
|
|
43
56
|
|
|
57
|
+
#ifdef TypedData_Make_Struct
|
|
58
|
+
static size_t rb_llhttp_memsize(const void *data) {
|
|
59
|
+
return data ? sizeof(llhttp_t) : 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static const rb_data_type_t rb_llhttp_type = {
|
|
63
|
+
"LLHttp::Parser",
|
|
64
|
+
{rb_llhttp_mark, rb_llhttp_free, rb_llhttp_memsize,},
|
|
65
|
+
0, 0, 0,
|
|
66
|
+
};
|
|
67
|
+
#endif
|
|
68
|
+
|
|
69
|
+
static llhttp_t *rb_llhttp_get(VALUE self) {
|
|
70
|
+
llhttp_t *parser;
|
|
71
|
+
|
|
72
|
+
#ifdef TypedData_Make_Struct
|
|
73
|
+
TypedData_Get_Struct(self, llhttp_t, &rb_llhttp_type, parser);
|
|
74
|
+
#else
|
|
75
|
+
Data_Get_Struct(self, llhttp_t, parser);
|
|
76
|
+
#endif
|
|
77
|
+
|
|
78
|
+
return parser;
|
|
79
|
+
}
|
|
80
|
+
|
|
44
81
|
VALUE rb_llhttp_allocate(VALUE klass) {
|
|
45
|
-
llhttp_t *parser
|
|
82
|
+
llhttp_t *parser;
|
|
83
|
+
#ifdef TypedData_Make_Struct
|
|
84
|
+
VALUE self = TypedData_Make_Struct(klass, llhttp_t, &rb_llhttp_type, parser);
|
|
85
|
+
#else
|
|
86
|
+
VALUE self = Data_Make_Struct(klass, llhttp_t, rb_llhttp_mark, rb_llhttp_free, parser);
|
|
87
|
+
#endif
|
|
46
88
|
|
|
47
89
|
// Set data to false so we know when the parser has been initialized.
|
|
48
90
|
//
|
|
49
91
|
parser->data = 0;
|
|
50
92
|
|
|
51
|
-
return
|
|
93
|
+
return self;
|
|
52
94
|
}
|
|
53
95
|
|
|
54
96
|
VALUE rb_llhttp_callback_call(VALUE delegate, ID method) {
|
|
55
97
|
return rb_funcall(delegate, method, 0);
|
|
56
98
|
}
|
|
57
99
|
|
|
58
|
-
void rb_llhttp_data_callback_call(VALUE delegate, ID method, char *data, size_t length) {
|
|
100
|
+
void rb_llhttp_data_callback_call(VALUE delegate, ID method, const char *data, size_t length) {
|
|
59
101
|
rb_funcall(delegate, method, 1, rb_str_new(data, length));
|
|
60
102
|
}
|
|
61
103
|
|
|
@@ -83,7 +125,7 @@ int rb_llhttp_on_chunk_header(llhttp_t *parser) {
|
|
|
83
125
|
return NUM2INT(rb_llhttp_callback_call(parserData->delegate, parserData->on_chunk_header));
|
|
84
126
|
}
|
|
85
127
|
|
|
86
|
-
int rb_llhttp_on_url(llhttp_t *parser, char *data, size_t length) {
|
|
128
|
+
int rb_llhttp_on_url(llhttp_t *parser, const char *data, size_t length) {
|
|
87
129
|
rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
|
|
88
130
|
|
|
89
131
|
rb_llhttp_data_callback_call(parserData->delegate, parserData->on_url, data, length);
|
|
@@ -91,7 +133,7 @@ int rb_llhttp_on_url(llhttp_t *parser, char *data, size_t length) {
|
|
|
91
133
|
return 0;
|
|
92
134
|
}
|
|
93
135
|
|
|
94
|
-
int rb_llhttp_on_status(llhttp_t *parser, char *data, size_t length) {
|
|
136
|
+
int rb_llhttp_on_status(llhttp_t *parser, const char *data, size_t length) {
|
|
95
137
|
rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
|
|
96
138
|
|
|
97
139
|
rb_llhttp_data_callback_call(parserData->delegate, parserData->on_status, data, length);
|
|
@@ -99,7 +141,7 @@ int rb_llhttp_on_status(llhttp_t *parser, char *data, size_t length) {
|
|
|
99
141
|
return 0;
|
|
100
142
|
}
|
|
101
143
|
|
|
102
|
-
int rb_llhttp_on_header_field(llhttp_t *parser, char *data, size_t length) {
|
|
144
|
+
int rb_llhttp_on_header_field(llhttp_t *parser, const char *data, size_t length) {
|
|
103
145
|
rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
|
|
104
146
|
|
|
105
147
|
rb_llhttp_data_callback_call(parserData->delegate, parserData->on_header_field, data, length);
|
|
@@ -107,7 +149,7 @@ int rb_llhttp_on_header_field(llhttp_t *parser, char *data, size_t length) {
|
|
|
107
149
|
return 0;
|
|
108
150
|
}
|
|
109
151
|
|
|
110
|
-
int rb_llhttp_on_header_value(llhttp_t *parser, char *data, size_t length) {
|
|
152
|
+
int rb_llhttp_on_header_value(llhttp_t *parser, const char *data, size_t length) {
|
|
111
153
|
rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
|
|
112
154
|
|
|
113
155
|
rb_llhttp_data_callback_call(parserData->delegate, parserData->on_header_value, data, length);
|
|
@@ -115,7 +157,7 @@ int rb_llhttp_on_header_value(llhttp_t *parser, char *data, size_t length) {
|
|
|
115
157
|
return 0;
|
|
116
158
|
}
|
|
117
159
|
|
|
118
|
-
int rb_llhttp_on_body(llhttp_t *parser, char *data, size_t length) {
|
|
160
|
+
int rb_llhttp_on_body(llhttp_t *parser, const char *data, size_t length) {
|
|
119
161
|
rb_llhttp_parser_data *parserData = (rb_llhttp_parser_data*) parser->data;
|
|
120
162
|
|
|
121
163
|
rb_llhttp_data_callback_call(parserData->delegate, parserData->on_body, data, length);
|
|
@@ -166,7 +208,9 @@ int rb_llhttp_on_header_value_complete(llhttp_t *parser) {
|
|
|
166
208
|
VALUE rb_llhttp_parse(VALUE self, VALUE data) {
|
|
167
209
|
llhttp_t *parser;
|
|
168
210
|
|
|
169
|
-
|
|
211
|
+
parser = rb_llhttp_get(self);
|
|
212
|
+
|
|
213
|
+
Check_Type(data, T_STRING);
|
|
170
214
|
|
|
171
215
|
enum llhttp_errno err = llhttp_execute(parser, RSTRING_PTR(data), RSTRING_LEN(data));
|
|
172
216
|
|
|
@@ -180,7 +224,7 @@ VALUE rb_llhttp_parse(VALUE self, VALUE data) {
|
|
|
180
224
|
VALUE rb_llhttp_finish(VALUE self) {
|
|
181
225
|
llhttp_t *parser;
|
|
182
226
|
|
|
183
|
-
|
|
227
|
+
parser = rb_llhttp_get(self);
|
|
184
228
|
|
|
185
229
|
enum llhttp_errno err = llhttp_finish(parser);
|
|
186
230
|
|
|
@@ -194,7 +238,7 @@ VALUE rb_llhttp_finish(VALUE self) {
|
|
|
194
238
|
VALUE rb_llhttp_reset(VALUE self) {
|
|
195
239
|
llhttp_t *parser;
|
|
196
240
|
|
|
197
|
-
|
|
241
|
+
parser = rb_llhttp_get(self);
|
|
198
242
|
|
|
199
243
|
llhttp_reset(parser);
|
|
200
244
|
|
|
@@ -204,7 +248,7 @@ VALUE rb_llhttp_reset(VALUE self) {
|
|
|
204
248
|
VALUE rb_llhttp_content_length(VALUE self) {
|
|
205
249
|
llhttp_t *parser;
|
|
206
250
|
|
|
207
|
-
|
|
251
|
+
parser = rb_llhttp_get(self);
|
|
208
252
|
|
|
209
253
|
return ULL2NUM(parser->content_length);
|
|
210
254
|
}
|
|
@@ -212,7 +256,7 @@ VALUE rb_llhttp_content_length(VALUE self) {
|
|
|
212
256
|
VALUE rb_llhttp_method_name(VALUE self) {
|
|
213
257
|
llhttp_t *parser;
|
|
214
258
|
|
|
215
|
-
|
|
259
|
+
parser = rb_llhttp_get(self);
|
|
216
260
|
|
|
217
261
|
return rb_str_new_cstr(llhttp_method_name(parser->method));
|
|
218
262
|
}
|
|
@@ -220,7 +264,7 @@ VALUE rb_llhttp_method_name(VALUE self) {
|
|
|
220
264
|
VALUE rb_llhttp_status_code(VALUE self) {
|
|
221
265
|
llhttp_t *parser;
|
|
222
266
|
|
|
223
|
-
|
|
267
|
+
parser = rb_llhttp_get(self);
|
|
224
268
|
|
|
225
269
|
return UINT2NUM(parser->status_code);
|
|
226
270
|
}
|
|
@@ -228,7 +272,7 @@ VALUE rb_llhttp_status_code(VALUE self) {
|
|
|
228
272
|
VALUE rb_llhttp_http_major(VALUE self) {
|
|
229
273
|
llhttp_t *parser;
|
|
230
274
|
|
|
231
|
-
|
|
275
|
+
parser = rb_llhttp_get(self);
|
|
232
276
|
|
|
233
277
|
return UINT2NUM(parser->http_major);
|
|
234
278
|
}
|
|
@@ -236,7 +280,7 @@ VALUE rb_llhttp_http_major(VALUE self) {
|
|
|
236
280
|
VALUE rb_llhttp_http_minor(VALUE self) {
|
|
237
281
|
llhttp_t *parser;
|
|
238
282
|
|
|
239
|
-
|
|
283
|
+
parser = rb_llhttp_get(self);
|
|
240
284
|
|
|
241
285
|
return UINT2NUM(parser->http_minor);
|
|
242
286
|
}
|
|
@@ -244,7 +288,7 @@ VALUE rb_llhttp_http_minor(VALUE self) {
|
|
|
244
288
|
VALUE rb_llhttp_keep_alive(VALUE self) {
|
|
245
289
|
llhttp_t *parser;
|
|
246
290
|
|
|
247
|
-
|
|
291
|
+
parser = rb_llhttp_get(self);
|
|
248
292
|
|
|
249
293
|
int ret = llhttp_should_keep_alive(parser);
|
|
250
294
|
|
|
@@ -254,7 +298,7 @@ VALUE rb_llhttp_keep_alive(VALUE self) {
|
|
|
254
298
|
static VALUE rb_llhttp_init(VALUE self, VALUE type) {
|
|
255
299
|
llhttp_t *parser;
|
|
256
300
|
|
|
257
|
-
|
|
301
|
+
parser = rb_llhttp_get(self);
|
|
258
302
|
|
|
259
303
|
llhttp_settings_t *settings = (llhttp_settings_t *)malloc(sizeof(llhttp_settings_t));
|
|
260
304
|
llhttp_settings_init(settings);
|
|
@@ -294,23 +338,23 @@ static VALUE rb_llhttp_init(VALUE self, VALUE type) {
|
|
|
294
338
|
}
|
|
295
339
|
|
|
296
340
|
if (rb_respond_to(parserData->delegate, parserData->on_url)) {
|
|
297
|
-
settings->on_url =
|
|
341
|
+
settings->on_url = rb_llhttp_on_url;
|
|
298
342
|
}
|
|
299
343
|
|
|
300
344
|
if (rb_respond_to(parserData->delegate, parserData->on_status)) {
|
|
301
|
-
settings->on_status =
|
|
345
|
+
settings->on_status = rb_llhttp_on_status;
|
|
302
346
|
}
|
|
303
347
|
|
|
304
348
|
if (rb_respond_to(parserData->delegate, parserData->on_header_field)) {
|
|
305
|
-
settings->on_header_field =
|
|
349
|
+
settings->on_header_field = rb_llhttp_on_header_field;
|
|
306
350
|
}
|
|
307
351
|
|
|
308
352
|
if (rb_respond_to(parserData->delegate, parserData->on_header_value)) {
|
|
309
|
-
settings->on_header_value =
|
|
353
|
+
settings->on_header_value = rb_llhttp_on_header_value;
|
|
310
354
|
}
|
|
311
355
|
|
|
312
356
|
if (rb_respond_to(parserData->delegate, parserData->on_body)) {
|
|
313
|
-
settings->on_body =
|
|
357
|
+
settings->on_body = rb_llhttp_on_body;
|
|
314
358
|
}
|
|
315
359
|
|
|
316
360
|
if (rb_respond_to(parserData->delegate, parserData->on_chunk_complete)) {
|
|
@@ -341,6 +385,10 @@ static VALUE rb_llhttp_init(VALUE self, VALUE type) {
|
|
|
341
385
|
}
|
|
342
386
|
|
|
343
387
|
void Init_llhttp_ext(void) {
|
|
388
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
|
389
|
+
rb_ext_ractor_safe(true);
|
|
390
|
+
#endif
|
|
391
|
+
|
|
344
392
|
mLLHttp = rb_const_get(rb_cObject, rb_intern("LLHttp"));
|
|
345
393
|
cParser = rb_const_get(mLLHttp, rb_intern("Parser"));
|
|
346
394
|
eError = rb_const_get(mLLHttp, rb_intern("Error"));
|
data/lib/llhttp/parser.rb
CHANGED
data/lib/llhttp/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bryan Powell
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
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:
|
|
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: []
|