llhttp 0.2.0 → 0.3.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: f3236c2a5b45eae39e4e7fa75d4d8e0adcd81c638bfb552d867f425fb03d86aa
4
- data.tar.gz: 17f5c72c3961cbb16408336caf9812e7d55f8cc5b0190d891b7f233474fa0382
3
+ metadata.gz: c3049572a0a42b0303696570fc91b7b657c716b014fc068ae549133b69aa6869
4
+ data.tar.gz: 4122c65a1c18f2f3d07cadb2e5b95089d4fd142382e9cb9a47138eec6d7a6b20
5
5
  SHA512:
6
- metadata.gz: c6317bcea1b73bd947949e8b0e94a8a14cc2ae70819e5d646c6e17ba1b5173c6605f0ff71fd4f7598b22bc005b7a182b819dbdad7a8c664dfae7d27a699c0d93
7
- data.tar.gz: 73b9c35367a69f805a06a79dbd365f124e146bd6baa200159db5611fd3cab37a50aa8d3ac5d36f182811e57a3ffbe29cdf7451e6a02cda90494789ddf48cb70d
6
+ metadata.gz: 9ea99585b4658d2520a61cc00df75a3a298c8c7b8f850928da65ae49d2ce3501e25e2b3659140859617135f7af933ec4e20639ad49e81ef335019892b1a553ff
7
+ data.tar.gz: 923b8dafbcd575d5fa27c722c52b4c7ae8a5be13044a589e045e8f4666913521539fbf808169e1beb9a6f345186a26bbc2285ea3643eb2197f1eaa3c2812a598
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
- ## v0.2.0
1
+ ## v0.3.0
2
2
 
3
- *unreleased*
3
+ *released on 2021-05-06*
4
+
5
+ * `chg` [#16](https://github.com/metabahn/llhttp/pull/16) Update mri 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.2.0](https://github.com/metabahn/llhttp/releases/tag/2021-04-06)
9
+
10
+ *released on 2021-04-06*
4
11
 
5
12
  * `chg` [#15](https://github.com/metabahn/llhttp/pull/15) Update mri 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(__VA_ARGS__); \
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, parser);
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
- HTTP_METHOD_MAP(HTTP_METHOD_GEN)
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, s);
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
- CALLBACK_MAYBE(s, on_url, s, p, endp - p);
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, s);
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
- CALLBACK_MAYBE(s, on_status, s, p, endp - p);
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, s);
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
- CALLBACK_MAYBE(s, on_header_field, s, p, endp - p);
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, s);
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
- CALLBACK_MAYBE(s, on_header_value, s, p, endp - p);
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, s);
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, s);
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, s);
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
- CALLBACK_MAYBE(s, on_body, s, p, endp - p);
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, s);
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, s);
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 5
28
- #define LLHTTP_VERSION_MINOR 1
29
- #define LLHTTP_VERSION_PATCH 0
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
- XX(34, PRI, PRI) \
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;
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LLHttp
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.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.2.0
4
+ version: 0.3.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-04-06 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby bindings for llhttp.
14
14
  email: bryan@metabahn.com
@@ -43,14 +43,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.5.0
46
+ version: 2.6.7
47
47
  required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
51
  version: '0'
52
52
  requirements: []
53
- rubygems_version: 3.2.4
53
+ rubygems_version: 3.2.15
54
54
  signing_key:
55
55
  specification_version: 4
56
56
  summary: Ruby bindings for llhttp.