class Protocol::HTTP2::SettingsFrame


---------------------------------------------------------------
| Value (32) |
-------------------------------——————————-+
| Identifier (16) |
-------------------------------
The SETTINGS frame conveys configuration parameters that affect how endpoints communicate, such as preferences and constraints on peer behavior. The SETTINGS frame is also used to acknowledge the receipt of those parameters. Individually, a SETTINGS parameter can also be referred to as a “setting”.

def apply(connection)

@parameter connection [Connection] The connection to apply the frame to.
Apply this SETTINGS frame to a connection for processing.
def apply(connection)
	connection.receive_settings(self)
end

def connection?

@returns [Boolean] Always returns true for SETTINGS frames.
Check if this frame applies to the connection level.
def connection?
	true
end

def pack(settings = [])

@parameter settings [Array] Array of [key, value] pairs to pack.
Pack settings parameters into the frame payload.
def pack(settings = [])
	super(settings.map{|s| s.pack(FORMAT)}.join)
end

def read_payload(stream)

@raises [FrameSizeError] If the frame length is invalid.
@raises [ProtocolError] If the frame is invalid.
@parameter stream [IO] The stream to read from.
Read and validate the SETTINGS frame payload.
def read_payload(stream)
	super
	
	if @stream_id != 0
		raise ProtocolError, "Settings apply to connection only, but stream_id was given"
	end
	
	if acknowledgement? and @length != 0
		raise FrameSizeError, "Settings acknowledgement must not contain payload: #{@payload.inspect}"
	end
	
	if (@length % 6) != 0
		raise FrameSizeError, "Invalid frame length"
	end
end

def unpack

@returns [Array] Array of [key, value] pairs representing settings.
Unpack settings parameters from the frame payload.
def unpack
	if buffer = super
		# TODO String#each_slice, or #each_unpack would be nice.
		buffer.scan(/....../m).map{|s| s.unpack(FORMAT)}
	else
		[]
	end
end