Class: Protocol::HTTP2::DataFrame

Inherits:
Frame
  • Object
show all
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

Methods included from Padded

#padded?, #unpack

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



41
42
43
# File 'lib/protocol/http2/data_frame.rb', line 41

def apply(connection)
  connection.receive_data(self)
end

#end_stream?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/protocol/http2/data_frame.rb', line 28

def end_stream?
  flag_set?(END_STREAM)
end

#inspectObject



45
46
47
# File 'lib/protocol/http2/data_frame.rb', line 45

def inspect
  "\#<#{self.class} stream_id=#{@stream_id} flags=#{@flags} #{@length || 0}b>"
end

#pack(data, *arguments, **options) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/protocol/http2/data_frame.rb', line 32

def pack(data, *arguments, **options)
  if data
    super
  else
    @length = 0
    set_flags(END_STREAM)
  end
end