lib/http/protocol/http2/connection.rb in http-protocol-0.1.1 vs lib/http/protocol/http2/connection.rb in http-protocol-0.2.0
- old
+ new
@@ -125,17 +125,22 @@
write_frame(frame)
end
def send_goaway(error_code = 0, message = "")
frame = GoawayFrame.new
- frame.pack @last_stream_id, error_code, message
+ frame.pack @remote_stream_id, error_code, message
write_frame(frame)
@state = :closed
end
+ def receive_goaway(frame)
+ @state = :closed
+ @framer.close
+ end
+
def write_frame(frame)
# puts "#{self.class} #{@state} write_frame: #{frame.inspect}"
@framer.write_frame(frame)
end
@@ -258,34 +263,45 @@
raise ProtocolError, "Exceeded maximum concurrent streams"
end
end
end
+ def deleted_stream? frame
+ frame.stream_id <= @local_stream_id or frame.stream_id <= @remote_stream_id
+ end
+
def receive_priority(frame)
if stream = @streams[frame.stream_id]
stream.receive_priority(frame)
+ elsif deleted_stream? frame
+ # ignore
else
- raise ProtocolError, "Bad stream"
+ stream = create_stream(frame.stream_id)
+ stream.receive_priority(frame)
+
+ @streams[frame.stream_id] = stream
end
end
def receive_reset_stream(frame)
if stream = @streams[frame.stream_id]
stream.receive_reset_stream(frame)
@streams.delete(stream.id)
+ elsif deleted_stream? frame
+ # ignore
else
raise ProtocolError, "Bad stream"
end
end
def receive_window_update(frame)
if frame.connection?
super
elsif stream = @streams[frame.stream_id]
stream.receive_window_update(frame)
- elsif frame.stream_id <= @local_stream_id or frame.stream_id <= @remote_stream_id
- # The stream was closed/deleted, ignore
+ elsif deleted_stream? frame
+ # ignore
else
raise ProtocolError, "Cannot update window of non-existant stream: #{frame.stream_id}"
end
end