Skip to content

Commit 0a65a84

Browse files
authored
Add llhttp-ffi gem (#1030)
* Add llhttp-ffi gem Minimal stubs for LLHttp::Parser, LLHttp::Delegate, and LLHttp::Error — just the surface referenced by the http gem's bundled sig/http.rbs (class Handler < LLHttp::Delegate, attr_reader parser: LLHttp::Parser) plus the Parser methods http's Response::Parser calls. Unblocks Steep users of the http gem, which otherwise fails signature load with RBS::NoSuperclassFoundError on LLHttp::Delegate. * Simplify test by removing the Delegate subclass Use LLHttp::Delegate.new directly instead of defining a subclass in the test. Drops the companion test.rbs since there's no custom Ruby class left to declare. Steep already validates the subclass case when it loads http.rbs (class Handler < LLHttp::Delegate), so the test doesn't need to exercise it too.
1 parent 2912890 commit 0a65a84

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

gems/llhttp-ffi/0.5/_test/test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require "llhttp"
2+
3+
parser = LLHttp::Parser.new(LLHttp::Delegate.new, type: :response)
4+
parser.reset
5+
parser << "HTTP/1.1 200 OK\r\n\r\n"
6+
parser.status_code
7+
parser.http_major
8+
parser.http_minor

gems/llhttp-ffi/0.5/llhttp-ffi.rbs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module LLHttp
2+
class Error < StandardError
3+
end
4+
5+
class Parser
6+
def initialize: (untyped delegate, ?type: Symbol) -> void
7+
def reset: () -> void
8+
def <<: (String data) -> void
9+
def status_code: () -> Integer
10+
def http_major: () -> Integer
11+
def http_minor: () -> Integer
12+
end
13+
14+
class Delegate
15+
def initialize: () -> void
16+
end
17+
end

0 commit comments

Comments
 (0)