lib/async/http/protocol/http2/stream.rb in async-http-0.56.5 vs lib/async/http/protocol/http2/stream.rb in async-http-0.56.6

- old
+ new

@@ -32,11 +32,10 @@ class Stream < ::Protocol::HTTP2::Stream def initialize(*) super @headers = nil - @trailer = nil # Input buffer, reading request body, or response body (receive_data): @length = nil @input = nil @@ -60,25 +59,19 @@ end end def receive_trailing_headers(headers, end_stream) headers.each do |key, value| - if @trailer.include?(key) - add_header(key, value) - else - raise ::Protocol::HTTP2::HeaderError, "Cannot add trailer #{key} as it was not specified as a trailer!" - end + add_header(key, value) end end def process_headers(frame) if @headers.nil? @headers = ::Protocol::HTTP::Headers.new self.receive_initial_headers(super, frame.end_stream?) - - @trailer = @headers[TRAILER] - elsif @trailer and frame.end_stream? + elsif frame.end_stream? self.receive_trailing_headers(super, frame.end_stream?) else raise ::Protocol::HTTP2::HeaderError, "Unable to process headers!" end @@ -150,10 +143,10 @@ if error send_reset_stream(::Protocol::HTTP2::Error::INTERNAL_ERROR) else # Write trailer? - if trailer + if trailer&.any? send_headers(nil, trailer, ::Protocol::HTTP2::END_STREAM) else send_data(nil, ::Protocol::HTTP2::END_STREAM) end end