class HeadersFrame
The HEADERS frame is used to open a stream, and additionally carries a header block fragment. HEADERS frames can be sent on a stream in the "idle", "reserved (local)", "open", or "half-closed (remote)" state.
+---------------+ |Pad Length? (8)| +-+-------------+-----------------------------------------------+ |E| Stream Dependency? (31) | +-+-------------+-----------------------------------------------+ | Weight? (8) | +-+-------------+-----------------------------------------------+ | Header Block Fragment () ... +---------------------------------------------------------------+ | Padding () ... +---------------------------------------------------------------+
Definitions
def priority?
Check if this frame contains priority information.
Signature
-
returns
Boolean
True if the PRIORITY flag is set.
Implementation
def priority?
flag_set?(PRIORITY)
end
def end_stream?
Check if this frame ends the stream.
Signature
-
returns
Boolean
True if the END_STREAM flag is set.
Implementation
def end_stream?
flag_set?(END_STREAM)
end
def unpack
Unpack the header block fragment from the frame.
Signature
-
returns
String
The unpacked header block data.
Implementation
def unpack
data = super
if priority?
# We no longer support priority frames, so strip the data:
data = data.byteslice(5, data.bytesize - 5)
end
return data
end
def pack(data, *arguments, **options)
Pack header block data into the frame.
Signature
-
parameter
data
String
The header block data to pack.
-
parameter
arguments
Array
Additional arguments.
-
parameter
options
Hash
Options for packing.
Implementation
def pack(data, *arguments, **options)
buffer = String.new.b
buffer << data
super(buffer, *arguments, **options)
end
def apply(connection)
Apply this HEADERS frame to a connection for processing.
Signature
-
parameter
connection
Connection
The connection to apply the frame to.
Implementation
def apply(connection)
connection.receive_headers(self)
end
def inspect
Get a string representation of the headers frame.
Signature
-
returns
String
Human-readable frame information.
Implementation
def inspect
"\#<#{self.class} stream_id=#{@stream_id} flags=#{@flags} #{@length || 0}b>"
end