Class: Protocol::HTTP2::DataFrame
- Includes:
- Padded
- Defined in:
- lib/protocol/http2/data_frame.rb
Overview
DATA frames convey arbitrary, variable-length sequences of octets associated with a stream. One or more DATA frames are used, for instance, to carry HTTP request or response payloads.
DATA frames MAY also contain padding. Padding can be added to DATA frames to obscure the size of messages.
--------------- |Pad Length? (8)| ---------------———————————————–+ | Data (*) … --------------------------------------------------------------- | Padding (*) … ---------------------------------------------------------------
Constant Summary collapse
- TYPE =
0x0
Constants inherited from Frame
Frame::HEADER_FORMAT, Frame::LENGTH_HISHIFT, Frame::LENGTH_LOMASK, Frame::STREAM_ID_MASK, Frame::VALID_LENGTH, Frame::VALID_STREAM_ID
Instance Attribute Summary
Attributes inherited from Frame
#flags, #length, #payload, #stream_id, #type
Instance Method Summary collapse
-
#apply(connection) ⇒ Object
Apply this DATA frame to a connection for processing.
-
#end_stream? ⇒ Boolean
Check if this frame marks the end of the stream.
-
#inspect ⇒ Object
Provide a readable representation of the frame for debugging.
-
#pack(data, *arguments, **options) ⇒ Object
Pack data into the frame, handling empty data as stream end.
Methods included from Padded
Methods inherited from Frame
#<=>, #clear_flags, #connection?, #flag_set?, #header, #initialize, parse_header, #read, #read_header, #read_payload, #set_flags, #to_ary, #unpack, #valid_type?, #write, #write_header, #write_payload
Constructor Details
This class inherits a constructor from Protocol::HTTP2::Frame
Instance Method Details
#apply(connection) ⇒ Object
Apply this DATA frame to a connection for processing.
49 50 51 |
# File 'lib/protocol/http2/data_frame.rb', line 49 def apply(connection) connection.receive_data(self) end |
#end_stream? ⇒ Boolean
Check if this frame marks the end of the stream.
30 31 32 |
# File 'lib/protocol/http2/data_frame.rb', line 30 def end_stream? flag_set?(END_STREAM) end |
#inspect ⇒ Object
Provide a readable representation of the frame for debugging.
55 56 57 |
# File 'lib/protocol/http2/data_frame.rb', line 55 def inspect "\#<#{self.class} stream_id=#{@stream_id} flags=#{@flags} #{@length || 0}b>" end |
#pack(data, *arguments, **options) ⇒ Object
Pack data into the frame, handling empty data as stream end.
38 39 40 41 42 43 44 45 |
# File 'lib/protocol/http2/data_frame.rb', line 38 def pack(data, *arguments, **) if data super else @length = 0 set_flags(END_STREAM) end end |