Class: HTTP2Adapter
- Inherits:
-
Object
- Object
- HTTP2Adapter
- Defined in:
- lib/polyphony/http/client/http2.rb
Overview
HTTP 2 adapter
Defined Under Namespace
Classes: StreamAdapter
Instance Method Summary collapse
- #allocate_stream ⇒ Object
- #allocate_stream_adapter ⇒ Object
-
#initialize(socket) ⇒ HTTP2Adapter
constructor
A new instance of HTTP2Adapter.
- #protocol ⇒ Object
Constructor Details
#initialize(socket) ⇒ HTTP2Adapter
Returns a new instance of HTTP2Adapter.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/polyphony/http/client/http2.rb', line 11 def initialize(socket) @socket = socket @client = HTTP2::Client.new @client.on(:frame) { |bytes| socket << bytes } # @client.on(:frame_received) do |frame| # puts "Received frame: #{frame.inspect}" # end # @client.on(:frame_sent) do |frame| # puts "Sent frame: #{frame.inspect}" # end @reader = spin do while (data = socket.readpartial(8192)) @client << data snooze end end end |
Instance Method Details
#allocate_stream ⇒ Object
34 35 36 |
# File 'lib/polyphony/http/client/http2.rb', line 34 def allocate_stream @client.new_stream end |
#allocate_stream_adapter ⇒ Object
30 31 32 |
# File 'lib/polyphony/http/client/http2.rb', line 30 def allocate_stream_adapter StreamAdapter.new(self) end |
#protocol ⇒ Object
38 39 40 |
# File 'lib/polyphony/http/client/http2.rb', line 38 def protocol :http2 end |