lib/http/2/stream.rb in http-2-0.8.3 vs lib/http/2/stream.rb in http-2-0.8.4
- old
+ new
@@ -123,27 +123,26 @@
# split and buffered based on maximum frame size and current stream flow
# control window size.
#
# @param frame [Hash]
def send(frame)
- transition(frame, true)
- frame[:stream] ||= @id
-
process_priority(frame) if frame[:type] == :priority
case frame[:type]
when :data
# @remote_window is maintained in send_data
send_data(frame)
when :window_update
- @local_window += frame[:increment]
- emit(:frame, frame)
+ manage_state(frame) do
+ @local_window += frame[:increment]
+ emit(:frame, frame)
+ end
else
- emit(:frame, frame)
+ manage_state(frame) do
+ emit(:frame, frame)
+ end
end
-
- complete_transition(frame)
end
# Sends a HEADERS frame containing HTTP response headers.
#
# @param headers [Array or Hash] Array of key-value pairs or Hash
@@ -600,8 +599,15 @@
@error = error
close(error) if @state != :closed
klass = error.to_s.split('_').map(&:capitalize).join
fail Error.const_get(klass), msg
+ end
+
+ def manage_state(frame)
+ transition(frame, true)
+ frame[:stream] ||= @id
+ yield
+ complete_transition(frame)
end
end
end