Class: Protocol::HTTP2::Priority

Inherits:
Struct
  • Object
show all
Defined in:
lib/protocol/http2/priority_frame.rb

Overview

Stream Dependency: A 31-bit stream identifier for the stream that this stream depends on (see Section 5.3). This field is only present if the PRIORITY flag is set.

Constant Summary collapse

FORMAT =
"NC".freeze
EXCLUSIVE =
1 << 31

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exclusiveObject

Returns the value of attribute exclusive

Returns:

  • (Object)

    the current value of exclusive



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

def exclusive
  @exclusive
end

#stream_dependencyObject

Returns the value of attribute stream_dependency

Returns:

  • (Object)

    the current value of stream_dependency



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

def stream_dependency
  @stream_dependency
end

#weightObject

Returns the value of attribute weight

Returns:

  • (Object)

    the current value of weight



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

def weight
  @weight
end

Class Method Details

.unpack(data) ⇒ Object



32
33
34
35
36
# File 'lib/protocol/http2/priority_frame.rb', line 32

def self.unpack(data)
  stream_dependency, weight = data.unpack(FORMAT)
  
  return self.new(stream_dependency & EXCLUSIVE != 0, stream_dependency & ~EXCLUSIVE, weight)
end

Instance Method Details

#packObject



38
39
40
41
42
43
44
# File 'lib/protocol/http2/priority_frame.rb', line 38

def pack
  if exclusive
    stream_dependency = self.stream_dependency | EXCLUSIVE
  end
  
  return [stream_dependency, self.weight].pack(FORMAT)
end