llhttp-ffi 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -2
- data/ext/llhttp/api.c +33 -18
- data/ext/llhttp/llhttp.h +60 -4
- data/lib/llhttp/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff154f16e10ab12ef357717c221e7682d7e82744de5b58900aa0d56e0992ffa3
|
4
|
+
data.tar.gz: 2b5643ad0b1e1fd004fa85efaeaf7418a30b2a53a9c299cbc31acde3c805fd94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e912489234b325d86a8e85c818e3481a371b6bea65f63b7cb96aa0d0fc0740cfe29c80f0c2279881ccf5f9ecbcf09a4f64bd9ecfa2b0e4bcdfec709bf605b77f
|
7
|
+
data.tar.gz: e5e80bee4a7be1868f4e6295c98c438e9d8d829b1709593986211c3ca3b89019991d64ef07dc00db22b9f08d95d2870da77e235129707d6e82099dd17f3beb05
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
## v0.
|
1
|
+
## v0.2.0
|
2
2
|
|
3
|
-
*
|
3
|
+
*released on 2021-05-06*
|
4
|
+
|
5
|
+
* `chg` [#17](https://github.com/metabahn/llhttp/pull/17) Update ffi to llhttp 6.0.1 ([bryanp](https://github.com/bryanp))
|
6
|
+
* `chg` [#18](https://github.com/metabahn/llhttp/pull/18) Drop support for Ruby 2.5 ([bryanp](https://github.com/bryanp))
|
7
|
+
|
8
|
+
## [v0.1.0](https://github.com/metabahn/llhttp/releases/tag/2021-04-06)
|
9
|
+
|
10
|
+
*released on 2021-04-06*
|
4
11
|
|
5
12
|
* `chg` [#14](https://github.com/metabahn/llhttp/pull/14) Update ffi to llhttp 5.1.0 ([bryanp](https://github.com/bryanp))
|
6
13
|
|
data/ext/llhttp/api.c
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
#include "llhttp.h"
|
29
29
|
|
30
|
-
#define CALLBACK_MAYBE(PARSER, NAME
|
30
|
+
#define CALLBACK_MAYBE(PARSER, NAME) \
|
31
31
|
do { \
|
32
32
|
const llhttp_settings_t* settings; \
|
33
33
|
settings = (const llhttp_settings_t*) (PARSER)->settings; \
|
@@ -35,7 +35,22 @@
|
|
35
35
|
err = 0; \
|
36
36
|
break; \
|
37
37
|
} \
|
38
|
-
err = settings->NAME(
|
38
|
+
err = settings->NAME((PARSER)); \
|
39
|
+
} while (0)
|
40
|
+
|
41
|
+
#define SPAN_CALLBACK_MAYBE(PARSER, NAME, START, LEN) \
|
42
|
+
do { \
|
43
|
+
const llhttp_settings_t* settings; \
|
44
|
+
settings = (const llhttp_settings_t*) (PARSER)->settings; \
|
45
|
+
if (settings == NULL || settings->NAME == NULL) { \
|
46
|
+
err = 0; \
|
47
|
+
break; \
|
48
|
+
} \
|
49
|
+
err = settings->NAME((PARSER), (START), (LEN)); \
|
50
|
+
if (err == -1) { \
|
51
|
+
err = HPE_USER; \
|
52
|
+
llhttp_set_error_reason((PARSER), "Span callback error in " #NAME); \
|
53
|
+
} \
|
39
54
|
} while (0)
|
40
55
|
|
41
56
|
void llhttp_init(llhttp_t* parser, llhttp_type_t type,
|
@@ -146,7 +161,7 @@ llhttp_errno_t llhttp_finish(llhttp_t* parser) {
|
|
146
161
|
|
147
162
|
switch (parser->finish) {
|
148
163
|
case HTTP_FINISH_SAFE_WITH_CB:
|
149
|
-
CALLBACK_MAYBE(parser, on_message_complete
|
164
|
+
CALLBACK_MAYBE(parser, on_message_complete);
|
150
165
|
if (err != HPE_OK) return err;
|
151
166
|
|
152
167
|
/* FALLTHROUGH */
|
@@ -222,7 +237,7 @@ const char* llhttp_errno_name(llhttp_errno_t err) {
|
|
222
237
|
const char* llhttp_method_name(llhttp_method_t method) {
|
223
238
|
#define HTTP_METHOD_GEN(NUM, NAME, STRING) case HTTP_##NAME: return #STRING;
|
224
239
|
switch (method) {
|
225
|
-
|
240
|
+
HTTP_ALL_METHOD_MAP(HTTP_METHOD_GEN)
|
226
241
|
default: abort();
|
227
242
|
}
|
228
243
|
#undef HTTP_METHOD_GEN
|
@@ -260,98 +275,98 @@ void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled) {
|
|
260
275
|
|
261
276
|
int llhttp__on_message_begin(llhttp_t* s, const char* p, const char* endp) {
|
262
277
|
int err;
|
263
|
-
CALLBACK_MAYBE(s, on_message_begin
|
278
|
+
CALLBACK_MAYBE(s, on_message_begin);
|
264
279
|
return err;
|
265
280
|
}
|
266
281
|
|
267
282
|
|
268
283
|
int llhttp__on_url(llhttp_t* s, const char* p, const char* endp) {
|
269
284
|
int err;
|
270
|
-
|
285
|
+
SPAN_CALLBACK_MAYBE(s, on_url, p, endp - p);
|
271
286
|
return err;
|
272
287
|
}
|
273
288
|
|
274
289
|
|
275
290
|
int llhttp__on_url_complete(llhttp_t* s, const char* p, const char* endp) {
|
276
291
|
int err;
|
277
|
-
CALLBACK_MAYBE(s, on_url_complete
|
292
|
+
CALLBACK_MAYBE(s, on_url_complete);
|
278
293
|
return err;
|
279
294
|
}
|
280
295
|
|
281
296
|
|
282
297
|
int llhttp__on_status(llhttp_t* s, const char* p, const char* endp) {
|
283
298
|
int err;
|
284
|
-
|
299
|
+
SPAN_CALLBACK_MAYBE(s, on_status, p, endp - p);
|
285
300
|
return err;
|
286
301
|
}
|
287
302
|
|
288
303
|
|
289
304
|
int llhttp__on_status_complete(llhttp_t* s, const char* p, const char* endp) {
|
290
305
|
int err;
|
291
|
-
CALLBACK_MAYBE(s, on_status_complete
|
306
|
+
CALLBACK_MAYBE(s, on_status_complete);
|
292
307
|
return err;
|
293
308
|
}
|
294
309
|
|
295
310
|
|
296
311
|
int llhttp__on_header_field(llhttp_t* s, const char* p, const char* endp) {
|
297
312
|
int err;
|
298
|
-
|
313
|
+
SPAN_CALLBACK_MAYBE(s, on_header_field, p, endp - p);
|
299
314
|
return err;
|
300
315
|
}
|
301
316
|
|
302
317
|
|
303
318
|
int llhttp__on_header_field_complete(llhttp_t* s, const char* p, const char* endp) {
|
304
319
|
int err;
|
305
|
-
CALLBACK_MAYBE(s, on_header_field_complete
|
320
|
+
CALLBACK_MAYBE(s, on_header_field_complete);
|
306
321
|
return err;
|
307
322
|
}
|
308
323
|
|
309
324
|
|
310
325
|
int llhttp__on_header_value(llhttp_t* s, const char* p, const char* endp) {
|
311
326
|
int err;
|
312
|
-
|
327
|
+
SPAN_CALLBACK_MAYBE(s, on_header_value, p, endp - p);
|
313
328
|
return err;
|
314
329
|
}
|
315
330
|
|
316
331
|
|
317
332
|
int llhttp__on_header_value_complete(llhttp_t* s, const char* p, const char* endp) {
|
318
333
|
int err;
|
319
|
-
CALLBACK_MAYBE(s, on_header_value_complete
|
334
|
+
CALLBACK_MAYBE(s, on_header_value_complete);
|
320
335
|
return err;
|
321
336
|
}
|
322
337
|
|
323
338
|
|
324
339
|
int llhttp__on_headers_complete(llhttp_t* s, const char* p, const char* endp) {
|
325
340
|
int err;
|
326
|
-
CALLBACK_MAYBE(s, on_headers_complete
|
341
|
+
CALLBACK_MAYBE(s, on_headers_complete);
|
327
342
|
return err;
|
328
343
|
}
|
329
344
|
|
330
345
|
|
331
346
|
int llhttp__on_message_complete(llhttp_t* s, const char* p, const char* endp) {
|
332
347
|
int err;
|
333
|
-
CALLBACK_MAYBE(s, on_message_complete
|
348
|
+
CALLBACK_MAYBE(s, on_message_complete);
|
334
349
|
return err;
|
335
350
|
}
|
336
351
|
|
337
352
|
|
338
353
|
int llhttp__on_body(llhttp_t* s, const char* p, const char* endp) {
|
339
354
|
int err;
|
340
|
-
|
355
|
+
SPAN_CALLBACK_MAYBE(s, on_body, p, endp - p);
|
341
356
|
return err;
|
342
357
|
}
|
343
358
|
|
344
359
|
|
345
360
|
int llhttp__on_chunk_header(llhttp_t* s, const char* p, const char* endp) {
|
346
361
|
int err;
|
347
|
-
CALLBACK_MAYBE(s, on_chunk_header
|
362
|
+
CALLBACK_MAYBE(s, on_chunk_header);
|
348
363
|
return err;
|
349
364
|
}
|
350
365
|
|
351
366
|
|
352
367
|
int llhttp__on_chunk_complete(llhttp_t* s, const char* p, const char* endp) {
|
353
368
|
int err;
|
354
|
-
CALLBACK_MAYBE(s, on_chunk_complete
|
369
|
+
CALLBACK_MAYBE(s, on_chunk_complete);
|
355
370
|
return err;
|
356
371
|
}
|
357
372
|
|
data/ext/llhttp/llhttp.h
CHANGED
@@ -24,9 +24,9 @@
|
|
24
24
|
#ifndef INCLUDE_LLHTTP_H_
|
25
25
|
#define INCLUDE_LLHTTP_H_
|
26
26
|
|
27
|
-
#define LLHTTP_VERSION_MAJOR
|
28
|
-
#define LLHTTP_VERSION_MINOR
|
29
|
-
#define LLHTTP_VERSION_PATCH
|
27
|
+
#define LLHTTP_VERSION_MAJOR 6
|
28
|
+
#define LLHTTP_VERSION_MINOR 0
|
29
|
+
#define LLHTTP_VERSION_PATCH 1
|
30
30
|
|
31
31
|
#ifndef LLHTTP_STRICT_MODE
|
32
32
|
# define LLHTTP_STRICT_MODE 0
|
@@ -254,7 +254,12 @@ typedef enum llhttp_method llhttp_method_t;
|
|
254
254
|
XX(31, LINK, LINK) \
|
255
255
|
XX(32, UNLINK, UNLINK) \
|
256
256
|
XX(33, SOURCE, SOURCE) \
|
257
|
-
|
257
|
+
|
258
|
+
|
259
|
+
#define RTSP_METHOD_MAP(XX) \
|
260
|
+
XX(1, GET, GET) \
|
261
|
+
XX(3, POST, POST) \
|
262
|
+
XX(6, OPTIONS, OPTIONS) \
|
258
263
|
XX(35, DESCRIBE, DESCRIBE) \
|
259
264
|
XX(36, ANNOUNCE, ANNOUNCE) \
|
260
265
|
XX(37, SETUP, SETUP) \
|
@@ -268,6 +273,54 @@ typedef enum llhttp_method llhttp_method_t;
|
|
268
273
|
XX(45, FLUSH, FLUSH) \
|
269
274
|
|
270
275
|
|
276
|
+
#define HTTP_ALL_METHOD_MAP(XX) \
|
277
|
+
XX(0, DELETE, DELETE) \
|
278
|
+
XX(1, GET, GET) \
|
279
|
+
XX(2, HEAD, HEAD) \
|
280
|
+
XX(3, POST, POST) \
|
281
|
+
XX(4, PUT, PUT) \
|
282
|
+
XX(5, CONNECT, CONNECT) \
|
283
|
+
XX(6, OPTIONS, OPTIONS) \
|
284
|
+
XX(7, TRACE, TRACE) \
|
285
|
+
XX(8, COPY, COPY) \
|
286
|
+
XX(9, LOCK, LOCK) \
|
287
|
+
XX(10, MKCOL, MKCOL) \
|
288
|
+
XX(11, MOVE, MOVE) \
|
289
|
+
XX(12, PROPFIND, PROPFIND) \
|
290
|
+
XX(13, PROPPATCH, PROPPATCH) \
|
291
|
+
XX(14, SEARCH, SEARCH) \
|
292
|
+
XX(15, UNLOCK, UNLOCK) \
|
293
|
+
XX(16, BIND, BIND) \
|
294
|
+
XX(17, REBIND, REBIND) \
|
295
|
+
XX(18, UNBIND, UNBIND) \
|
296
|
+
XX(19, ACL, ACL) \
|
297
|
+
XX(20, REPORT, REPORT) \
|
298
|
+
XX(21, MKACTIVITY, MKACTIVITY) \
|
299
|
+
XX(22, CHECKOUT, CHECKOUT) \
|
300
|
+
XX(23, MERGE, MERGE) \
|
301
|
+
XX(24, MSEARCH, M-SEARCH) \
|
302
|
+
XX(25, NOTIFY, NOTIFY) \
|
303
|
+
XX(26, SUBSCRIBE, SUBSCRIBE) \
|
304
|
+
XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \
|
305
|
+
XX(28, PATCH, PATCH) \
|
306
|
+
XX(29, PURGE, PURGE) \
|
307
|
+
XX(30, MKCALENDAR, MKCALENDAR) \
|
308
|
+
XX(31, LINK, LINK) \
|
309
|
+
XX(32, UNLINK, UNLINK) \
|
310
|
+
XX(33, SOURCE, SOURCE) \
|
311
|
+
XX(34, PRI, PRI) \
|
312
|
+
XX(35, DESCRIBE, DESCRIBE) \
|
313
|
+
XX(36, ANNOUNCE, ANNOUNCE) \
|
314
|
+
XX(37, SETUP, SETUP) \
|
315
|
+
XX(38, PLAY, PLAY) \
|
316
|
+
XX(39, PAUSE, PAUSE) \
|
317
|
+
XX(40, TEARDOWN, TEARDOWN) \
|
318
|
+
XX(41, GET_PARAMETER, GET_PARAMETER) \
|
319
|
+
XX(42, SET_PARAMETER, SET_PARAMETER) \
|
320
|
+
XX(43, REDIRECT, REDIRECT) \
|
321
|
+
XX(44, RECORD, RECORD) \
|
322
|
+
XX(45, FLUSH, FLUSH) \
|
323
|
+
|
271
324
|
|
272
325
|
#ifdef __cplusplus
|
273
326
|
} /* extern "C" */
|
@@ -297,6 +350,7 @@ struct llhttp_settings_s {
|
|
297
350
|
/* Possible return values 0, -1, `HPE_PAUSED` */
|
298
351
|
llhttp_cb on_message_begin;
|
299
352
|
|
353
|
+
/* Possible return values 0, -1, HPE_USER */
|
300
354
|
llhttp_data_cb on_url;
|
301
355
|
llhttp_data_cb on_status;
|
302
356
|
llhttp_data_cb on_header_field;
|
@@ -313,6 +367,7 @@ struct llhttp_settings_s {
|
|
313
367
|
*/
|
314
368
|
llhttp_cb on_headers_complete;
|
315
369
|
|
370
|
+
/* Possible return values 0, -1, HPE_USER */
|
316
371
|
llhttp_data_cb on_body;
|
317
372
|
|
318
373
|
/* Possible return values 0, -1, `HPE_PAUSED` */
|
@@ -325,6 +380,7 @@ struct llhttp_settings_s {
|
|
325
380
|
llhttp_cb on_chunk_header;
|
326
381
|
llhttp_cb on_chunk_complete;
|
327
382
|
|
383
|
+
/* Information-only callbacks, return value is ignored */
|
328
384
|
llhttp_cb on_url_complete;
|
329
385
|
llhttp_cb on_status_complete;
|
330
386
|
llhttp_cb on_header_field_complete;
|
data/lib/llhttp/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2021-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-compiler
|
@@ -72,14 +72,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.
|
75
|
+
version: 2.6.7
|
76
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
|
-
rubygems_version: 3.2.
|
82
|
+
rubygems_version: 3.2.15
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Ruby FFI bindings for llhttp.
|