llhttp-ffi 0.5.1 → 0.5.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: 702d7047da5b1893a33738b779197039a335b983cd803bda251a470045b52c34
4
- data.tar.gz: c01172f662009de49ab60252eec448fddcb583dbfc0e5c6ba16724ea3326d5de
3
+ metadata.gz: 99170bbd6cba8ca71bc354ac1453c1aa8dd1bbc8d0cbf4878a6740494cf09b8e
4
+ data.tar.gz: 1bc54c62ec2477fdca4e5543047a946b8097b3035376cc8f8554710970e42005
5
5
  SHA512:
6
- metadata.gz: dd6c702961011ca56355c3d7b829ab261e30eb885ef69f666fc6a4399d5bf7062f2cbea4bd4686b27600b04096fd831ce404602a99a6fdc28a2110b59948d750
7
- data.tar.gz: fbdd9712f826af82c29c95af8df4e75de4e3b085aca85ad8bb1baaebf5b1d2c820b7bc14bb850052f8b5b6ed104536a925aef93175aa19ba2765671fdd5b4ada
6
+ metadata.gz: b72004892dd2bd5af4b5b34b7fe6bf1c56ac20e758930f61286e18b432591ead1a31e945dde3951bd1ef2b86510740f8bd26b4556c2084c89a8673d17b690de3
7
+ data.tar.gz: 397e89d28bb5b098a70f96d3e563f9e930af7151e4332d6cb7ece165e219b13983c34dbb5681e9c3209b027bf9dbc31dc52c301a11fecdb18687d3195d687c75
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [v0.5.2](https://github.com/bryanp/llhttp/releases/tag/2026-12-05)
2
+
3
+ *released on 2026-12-05*
4
+
5
+ * `fix` [#45](https://github.com/bryanp/llhttp/pull/45) Raise TypeError when parsing data that is not a string ([bryanp](https://github.com/bryanp))
6
+ * `fix` [#43](https://github.com/bryanp/llhttp/pull/43) Fix truncation of multibyte input ([bryanp](https://github.com/bryanp))
7
+ * `fix` [#39](https://github.com/bryanp/llhttp/pull/39) Retain callback procs for the lifetime of the parser ([sferik](https://github.com/sferik))
8
+
1
9
  ## [v0.5.1](https://github.com/bryanp/llhttp/releases/tag/2025-03-11)
2
10
 
3
11
  *released on 2025-03-11*
data/lib/llhttp/parser.rb CHANGED
@@ -62,9 +62,17 @@ module LLHttp
62
62
 
63
63
  @callbacks = Callbacks.new
64
64
 
65
+ # Keep explicit references to the callback procs. JRuby's FFI does not
66
+ # retain Ruby references to procs assigned into FFI::Struct callback
67
+ # fields, so without these the JVM may collect the procs and reclaim
68
+ # their native trampolines while the parser is still in use, after
69
+ # which llhttp_execute completes without invoking any callbacks.
70
+ @callback_procs = []
71
+
65
72
  (CALLBACKS + CALLBACKS_WITH_DATA).each do |callback|
66
73
  if delegate.respond_to?(callback)
67
- @callbacks[callback] = method(callback).to_proc
74
+ @callback_procs << (callback_proc = method(callback).to_proc)
75
+ @callbacks[callback] = callback_proc
68
76
  end
69
77
  end
70
78
 
@@ -76,7 +84,9 @@ module LLHttp
76
84
  # [public] Parse the given data.
77
85
  #
78
86
  def parse(data)
79
- errno = LLHttp.llhttp_execute(@pointer, data, data.length)
87
+ raise TypeError, "wrong argument type #{data.class} (expected String)" unless data.is_a?(String)
88
+
89
+ errno = LLHttp.llhttp_execute(@pointer, data, data.bytesize)
80
90
  raise build_error(errno) if errno > 0
81
91
  end
82
92
  alias_method :<<, :parse
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LLHttp
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.2"
5
5
 
6
6
  # [public] LLHttp's current version.
7
7
  #
data/lib/llhttp.rb CHANGED
@@ -10,6 +10,7 @@ module LLHttp
10
10
  require_relative "llhttp/version"
11
11
 
12
12
  extend FFI::Library
13
+
13
14
  ffi_lib(FFI::Compiler::Loader.find("llhttp-ext"))
14
15
 
15
16
  callback :llhttp_data_cb, [:pointer, :size_t], :void
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llhttp-ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-03-12 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: ffi-compiler
@@ -50,10 +49,6 @@ files:
50
49
  - README.md
51
50
  - ext/Rakefile
52
51
  - ext/aarch64-darwin/libllhttp-ext.bundle
53
- - ext/aarch64-darwin/llhttp/api.o
54
- - ext/aarch64-darwin/llhttp/http.o
55
- - ext/aarch64-darwin/llhttp/llhttp.o
56
- - ext/aarch64-darwin/llhttp/llhttp_ext.o
57
52
  - ext/llhttp/api.c
58
53
  - ext/llhttp/extconf.rb
59
54
  - ext/llhttp/http.c
@@ -69,7 +64,6 @@ homepage: https://github.com/bryanp/llhttp/
69
64
  licenses:
70
65
  - MPL-2.0
71
66
  metadata: {}
72
- post_install_message:
73
67
  rdoc_options: []
74
68
  require_paths:
75
69
  - lib
@@ -84,8 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
78
  - !ruby/object:Gem::Version
85
79
  version: '0'
86
80
  requirements: []
87
- rubygems_version: 3.5.11
88
- signing_key:
81
+ rubygems_version: 4.0.6
89
82
  specification_version: 4
90
83
  summary: Ruby FFI bindings for llhttp.
91
84
  test_files: []
Binary file
Binary file
Binary file
Binary file