Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/async/http/protocol/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def initialize(http1: HTTP1, http2: HTTP2)
@http2 = http2
end

# The names of all supported protocols.
# @returns [Array(String)] The supported protocol names.
def names
(@http2.names + @http1.names).uniq
end

# Determine if the inbound connection is HTTP/1 or HTTP/2.
#
# @parameter stream [IO::Stream] The stream to detect the protocol for.
Expand Down
4 changes: 4 additions & 0 deletions releases.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Releases

## Unreleased

- Exposed all supported protocol names from the plaintext HTTP protocol negotiator.

## v0.96.0

- Made `metrics` and `traces` optional runtime dependencies. Applications that use the providers should depend on the corresponding gem and require the provider explicitly.
Expand Down
12 changes: 12 additions & 0 deletions test/async/http/protocol/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
it "has a default instance" do
expect(protocol).to be_a Async::HTTP::Protocol::HTTP
end

it "exposes the supported protocol names" do
expect(subject.names).to be == ["h2", "http/1.1", "http/1.0"]
end
end

with "configured protocols" do
let(:protocol) {subject.new(http1: Async::HTTP::Protocol::HTTP11, http2: Async::HTTP::Protocol::HTTP2)}

it "exposes their supported protocol names" do
expect(protocol.names).to be == ["h2", "http/1.1"]
end
end

with "#protocol_for" do
Expand Down
Loading