class Protocol::HTTP2::Settings
def difference(other)
def difference(other) changes = [] if @header_table_size != other.header_table_size changes << [HEADER_TABLE_SIZE, @header_table_size] end if @enable_push != other.enable_push changes << [ENABLE_PUSH, @enable_push] end if @maximum_concurrent_streams != other.maximum_concurrent_streams changes << [MAXIMUM_CONCURRENT_STREAMS, @maximum_concurrent_streams] end if @initial_window_size != other.initial_window_size changes << [INITIAL_WINDOW_SIZE, @initial_window_size] end if @maximum_frame_size != other.maximum_frame_size changes << [MAXIMUM_FRAME_SIZE, @maximum_frame_size] end if @maximum_header_list_size != other.maximum_header_list_size changes << [MAXIMUM_HEADER_LIST_SIZE, @maximum_header_list_size] end if @enable_connect_protocol != other.enable_connect_protocol changes << [ENABLE_CONNECT_PROTOCOL, @enable_connect_protocol] end return changes end
def enable_connect_protocol= value
def enable_connect_protocol= value if value == 0 or value == 1 @enable_connect_protocol = value else raise ProtocolError, "Invalid value for enable_connect_protocol: #{value}" end end
def enable_connect_protocol?
def enable_connect_protocol? @enable_connect_protocol == 1 end
def enable_push= value
def enable_push= value if value == 0 or value == 1 @enable_push = value else raise ProtocolError, "Invalid value for enable_push: #{value}" end end
def enable_push?
def enable_push? @enable_push == 1 end
def initial_window_size= value
def initial_window_size= value if value <= MAXIMUM_ALLOWED_WINDOW_SIZE @initial_window_size = value else raise ProtocolError, "Invalid value for initial_window_size: #{value} > #{MAXIMUM_ALLOWED_WINDOW_SIZE}" end end
def initialize
def initialize # These limits are taken from the RFC: # https://tools.ietf.org/html/rfc7540#section-6.5.2 @header_table_size = 4096 @enable_push = 1 @maximum_concurrent_streams = 0xFFFFFFFF @initial_window_size = 0xFFFF # 2**16 - 1 @maximum_frame_size = 0x4000 # 2**14 @maximum_header_list_size = 0xFFFFFFFF @enable_connect_protocol = 0 end
def maximum_frame_size= value
def maximum_frame_size= value if value > MAXIMUM_ALLOWED_FRAME_SIZE raise ProtocolError, "Invalid value for maximum_frame_size: #{value} > #{MAXIMUM_ALLOWED_FRAME_SIZE}" elsif value < MINIMUM_ALLOWED_FRAME_SIZE raise ProtocolError, "Invalid value for maximum_frame_size: #{value} < #{MINIMUM_ALLOWED_FRAME_SIZE}" else @maximum_frame_size = value end end
def update(changes)
def update(changes) changes.each do |key, value| if name = ASSIGN[key] self.send(name, value) end end end