diff options
-rw-r--r-- | lib/plum/client.rb | 1 | ||||
-rw-r--r-- | lib/plum/client/response.rb | 1 | ||||
-rw-r--r-- | lib/plum/connection.rb | 3 | ||||
-rw-r--r-- | lib/plum/event_emitter.rb | 5 | ||||
-rw-r--r-- | lib/plum/frame_factory.rb | 3 | ||||
-rw-r--r-- | lib/plum/server/http_connection.rb | 1 | ||||
-rw-r--r-- | lib/plum/stream.rb | 5 | ||||
-rw-r--r-- | lib/plum/stream_utils.rb | 1 |
8 files changed, 9 insertions, 11 deletions
diff --git a/lib/plum/client.rb b/lib/plum/client.rb index 020b372..6c3b16d 100644 --- a/lib/plum/client.rb +++ b/lib/plum/client.rb @@ -30,6 +30,7 @@ module Plum if host.is_a?(IO) @socket = host else + @socket = nil @host = host @port = port || (config[:scheme] == "https" ? 443 : 80) end diff --git a/lib/plum/client/response.rb b/lib/plum/client/response.rb index 9e50f02..2cc01a8 100644 --- a/lib/plum/client/response.rb +++ b/lib/plum/client/response.rb @@ -12,6 +12,7 @@ module Plum @failed = false @body = [] @auto_decode = auto_decode + @on_chunk = @on_finish = nil end # Returns the HTTP status code. diff --git a/lib/plum/connection.rb b/lib/plum/connection.rb index 5469a4d..3172eb0 100644 --- a/lib/plum/connection.rb +++ b/lib/plum/connection.rb @@ -201,7 +201,8 @@ module Plum goaway close - last_id = frame.payload.uint32(0) + # TODO: how handle it? + # last_id = frame.payload.uint32(0) error_code = frame.payload.uint32(4) message = frame.payload.byteslice(8, frame.length - 8) if error_code > 0 diff --git a/lib/plum/event_emitter.rb b/lib/plum/event_emitter.rb index e0684dd..310c247 100644 --- a/lib/plum/event_emitter.rb +++ b/lib/plum/event_emitter.rb @@ -5,14 +5,13 @@ module Plum # @param name [Symbol] The name of event. # @yield Gives event-specific parameters. def on(name, &blk) - @callbacks ||= {} - (@callbacks[name] ||= []) << blk + ((@callbacks ||= {})[name] ||= []) << blk end # Invokes an event and call handlers with args. # @param name [Symbol] The identifier of event. def callback(name, *args) - @callbacks&.[](name)&.each { |cb| cb.call(*args) } + (@callbacks ||= {})[name]&.each { |cb| cb.call(*args) } end end end diff --git a/lib/plum/frame_factory.rb b/lib/plum/frame_factory.rb index b4919e5..886b7f4 100644 --- a/lib/plum/frame_factory.rb +++ b/lib/plum/frame_factory.rb @@ -27,7 +27,8 @@ module Plum # @param ack [Symbol] Pass :ack to create an ACK frame. # @param args [Hash<Symbol, Integer>] The settings values to send. def settings(ack = nil, **args) - payload = args.inject(String.new) {|payload, (key, value)| + payload = String.new + args.each { |key, value| id = Frame::SETTINGS_TYPE[key] or raise ArgumentError.new("invalid settings type") payload.push_uint16(id) payload.push_uint32(value) diff --git a/lib/plum/server/http_connection.rb b/lib/plum/server/http_connection.rb index 642bcbc..0a49932 100644 --- a/lib/plum/server/http_connection.rb +++ b/lib/plum/server/http_connection.rb @@ -65,7 +65,6 @@ module Plum def process_first_request(parser, headers, body) encoder = HPACK::Encoder.new(0, indexing: false) # don't pollute connection's HPACK context stream = stream(1) - max_frame_size = local_settings[:max_frame_size] nheaders = headers.merge({ ":method" => parser.http_method, ":path" => parser.request_url, ":authority" => headers["host"] }) diff --git a/lib/plum/stream.rb b/lib/plum/stream.rb index 85fe311..ebc604b 100644 --- a/lib/plum/stream.rb +++ b/lib/plum/stream.rb @@ -76,10 +76,7 @@ module Plum @weight = weight end - if parent - @parent = parent - @parent.children << self - end + (@parent = parent)&.children&.add(self) if exclusive != nil @exclusive = exclusive diff --git a/lib/plum/stream_utils.rb b/lib/plum/stream_utils.rb index 5fd6cc2..7607815 100644 --- a/lib/plum/stream_utils.rb +++ b/lib/plum/stream_utils.rb @@ -18,7 +18,6 @@ module Plum # @param headers [Enumerable<String, String>] The response headers. # @param end_stream [Boolean] Set END_STREAM flag or not. def send_headers(headers, end_stream:) - max = @connection.remote_settings[:max_frame_size] encoded = @connection.hpack_encoder.encode(headers) frame = Frame.headers(id, encoded, end_headers: true, end_stream: end_stream) send frame |