Method: HTTP::Protocol::HTTP2::FlowControl#consume_remote_window

Defined in:
lib/http/protocol/http2/flow_control.rb

#consume_remote_window(frame) ⇒ Object

Keep track of the amount of data sent, and fail if is too much.



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/http/protocol/http2/flow_control.rb', line 39

def consume_remote_window(frame)
  amount = frame.length
  
  # Frames with zero length with the END_STREAM flag set (that is, an empty DATA frame) MAY be sent if there is no available space in either flow-control window.
  if amount.zero? and frame.end_stream?
    # It's okay, we can send. No need to consume, it's empty anyway.
  elsif amount >= 0 and amount <= @remote_window.available
    @remote_window.consume(amount)
  else
    raise FlowControlError, "Trying to send #{frame.inspect}, exceeded window size: #{@remote_window.available}"
  end
end