class SettingsFrame
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".
+-------------------------------+ | Identifier (16) | +-------------------------------+-------------------------------+ | Value (32) | +---------------------------------------------------------------+
Definitions
def connection?
Check if this frame applies to the connection level.
Signature
-
returns
Boolean
Always returns true for SETTINGS frames.
Implementation
def connection?
true
end
def unpack
Unpack settings parameters from the frame payload.
Signature
-
returns
Array
Array of [key, value] pairs representing settings.
Implementation
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
def pack(settings = [])
Pack settings parameters into the frame payload.
Signature
-
parameter
settings
Array
Array of [key, value] pairs to pack.
Implementation
def pack(settings = [])
super(settings.map{|s| s.pack(FORMAT)}.join)
end
def apply(connection)
Apply this SETTINGS frame to a connection for processing.
Signature
-
parameter
connection
Connection
The connection to apply the frame to.
Implementation
def apply(connection)
connection.receive_settings(self)
end
def read_payload(stream)
Read and validate the SETTINGS frame payload.
Signature
-
parameter
stream
IO
The stream to read from.
-
raises
ProtocolError
If the frame is invalid.
-
raises
FrameSizeError
If the frame length is invalid.
Implementation
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