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

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

Constant Summary collapse

PREFACE_BYTES =
"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"

Instance Attribute Summary collapse

Attributes inherited from H2Command

#flags, #stream_id

Instance Method Summary collapse

Constructor Details

#initialize(stream_id, flags = nil) ⇒ CmdPreface

Returns a new instance of CmdPreface.



24
25
26
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_preface.rb', line 24

def initialize(stream_id, flags=nil)
  super(H2Type::PREFACE, stream_id, flags)
end

Instance Attribute Details

#protocolObject (readonly)

Returns the value of attribute protocol.



22
23
24
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_preface.rb', line 22

def protocol
  @protocol
end

Instance Method Details

#handle(cmd_handler) ⇒ Object



40
41
42
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_preface.rb', line 40

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

#pack(pkt) ⇒ Object



35
36
37
38
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_preface.rb', line 35

def pack(pkt)
  acc = pkt.new_h2_data_accessor()
  acc.put_bytes(PREFACE_BYTES)
end

#unpack(pkt) ⇒ Object



28
29
30
31
32
33
# File 'lib/baykit/bayserver/docker/http/h2/command/cmd_preface.rb', line 28

def unpack(pkt)
  acc = pkt.new_data_accessor()
  preface_data = StringUtil.alloc(24)
  acc.get_bytes(preface_data, 0, 24)
  @protocol = preface_data[6, 8]
end