Class: Baykit::BayServer::Docker::Http::H2::Command::CmdData

Inherits:
H2Command
  • Object
show all
Includes:
Baykit::BayServer::Docker::Http::H2
Defined in:
lib/baykit/bayserver/docker/http/h2/command/cmd_data.rb

Instance Attribute Summary collapse

Attributes inherited from H2Command

#flags, #stream_id

Instance Method Summary collapse

Constructor Details

#initialize(stream_id, flags, data = nil, start = nil, len = nil) ⇒ CmdData

Returns a new instance of CmdData.



31
32
33
34
35
36
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_data.rb', line 31

def initialize(stream_id, flags, data=nil, start=nil, len=nil)
  super(H2Type::DATA, stream_id, flags)
  @data = data
  @start = start
  @length = len
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



29
30
31
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_data.rb', line 29

def data
  @data
end

#lengthObject (readonly)

Returns the value of attribute length.



28
29
30
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_data.rb', line 28

def length
  @length
end

#startObject (readonly)

This class refers external byte array, so this IS NOT mutable



27
28
29
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_data.rb', line 27

def start
  @start
end

Instance Method Details

#handle(cmd_handler) ⇒ Object



54
55
56
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_data.rb', line 54

def handle(cmd_handler)
  return cmd_handler.handle_data(self)
end

#pack(pkt) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_data.rb', line 45

def pack(pkt)
  acc = pkt.new_data_accessor()
  if @flags.padded?
    raise RuntimeError.new("Padding not supported")
  end
  acc.put_bytes(@data, @start, @length)
  super
end

#unpack(pkt) ⇒ Object



38
39
40
41
42
43
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_data.rb', line 38

def unpack(pkt)
  super
  @data = pkt.buf
  @start = pkt.header_len
  @length = pkt.data_len()
end