Class: Baykit::BayServer::Docker::Http::H2::H2Packet

Inherits:
Protocol::Packet
  • Object
show all
Includes:
Baykit::BayServer::Docker::Http::H2, Protocol
Defined in:
lib/baykit/bayserver/docker/http/h2/h2_packet.rb

Defined Under Namespace

Classes: H2DataAccessor, H2HeaderAccessor

Constant Summary collapse

MAX_PAYLOAD_LEN =

2^24-1 = 16777215 = 16MB-1

0x00FFFFFF
DEFAULT_PAYLOAD_MAXLEN =

2^14 = 16384 = 16KB

0x00004000
FRAME_HEADER_LEN =
9
NO_ERROR =
0x0
PROTOCOL_ERROR =
0x1
INTERNAL_ERROR =
0x2
FLOW_CONTROL_ERROR =
0x3
SETTINGS_TIMEOUT =
0x4
STREAM_CLOSED =
0x5
FRAME_SIZE_ERROR =
0x6
REFUSED_STREAM =
0x7
CANCEL =
0x8
COMPRESSION_ERROR =
0x9
CONNECT_ERROR =
0xa
ENHANCE_YOUR_CALM =
0xb
INADEQUATE_SECURITY =
0xc
HTTP_1_1_REQUIRED =
0xd

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ H2Packet

Returns a new instance of H2Packet.



150
151
152
153
154
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 150

def initialize(type)
  super(type, FRAME_HEADER_LEN, DEFAULT_PAYLOAD_MAXLEN)
  @flags = H2Flags::FLAGS_NONE
  @stream_id = -1
end

Instance Attribute Details

#flagsObject

Returns the value of attribute flags.



147
148
149
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 147

def flags
  @flags
end

#stream_idObject

Returns the value of attribute stream_id.



148
149
150
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 148

def stream_id
  @stream_id
end

Class Method Details

.consolidate_flag_and_int32(flag, val) ⇒ Object



186
187
188
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 186

def self.consolidate_flag_and_int32(flag, val)
  ((flag & 1) << 31) | (val & 0x7FFFFFFF)
end

.extract_flag(val) ⇒ Object



182
183
184
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 182

def self.extract_flag(val)
  (val & 0x80000000) >> 31 & 1
end

.extract_int31(val) ⇒ Object



178
179
180
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 178

def self.extract_int31(val)
  val & 0x7FFFFFFF
end

.make_stream_dependency32(excluded, dep) ⇒ Object



190
191
192
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 190

def self.make_stream_dependency32(excluded, dep)
  (excluded ? 1 : 0) << 31 | extract_int31(dep)
end

Instance Method Details

#new_h2_data_accessorObject



174
175
176
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 174

def new_h2_data_accessor
  H2DataAccessor.new(self, @header_len, -1)
end

#new_h2_header_accessorObject



170
171
172
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 170

def new_h2_header_accessor
  H2HeaderAccessor.new(self, 0, @header_len)
end

#pack_headerObject



162
163
164
165
166
167
168
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 162

def pack_header
  acc = new_h2_header_accessor()
  acc.put_int24(data_len())
  acc.put_byte(@type)
  acc.put_byte(@flags.flags)
  acc.put_int(H2Packet.extract_int31(stream_id))
end

#resetObject



156
157
158
159
160
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 156

def reset
  @flags = H2Flags::FLAGS_NONE
  @stream_id = -1
  super
end

#to_sObject



194
195
196
# File 'lib/baykit/bayserver/docker/http/h2/h2_packet.rb', line 194

def to_s
  "H2Packet(#{@type}) headerLen=#{@header_len} dataLen=#{data_len()} stm=#{@stream_id} flags=#{@flags}"
end