class Protocol::HTTP2::Priority

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.

Constants

EXCLUSIVE
FORMAT

Public Class Methods

default(stream_dependency = 0, weight = 16) click to toggle source

All streams are initially assigned a non-exclusive dependency on stream 0x0. Pushed streams (Section 8.2) initially depend on their associated stream. In both cases, streams are assigned a default weight of 16.

# File lib/protocol/http2/priority_frame.rb, line 35
def self.default(stream_dependency = 0, weight = 16)
        self.new(false, stream_dependency, weight)
end
unpack(data) click to toggle source
# File lib/protocol/http2/priority_frame.rb, line 39
def self.unpack(data)
        stream_dependency, weight = data.unpack(FORMAT)
        
        # Weight:  An unsigned 8-bit integer representing a priority weight for the stream (see Section 5.3).  Add one to the value to obtain a weight between 1 and 256.  This field is only present if the PRIORITY flag is set.
        return self.new(stream_dependency & EXCLUSIVE != 0, stream_dependency & ~EXCLUSIVE, weight + 1)
end

Public Instance Methods

pack() click to toggle source
# File lib/protocol/http2/priority_frame.rb, line 46
def pack
        if exclusive
                stream_dependency = self.stream_dependency | EXCLUSIVE
        else
                stream_dependency = self.stream_dependency
        end
        
        return [stream_dependency, self.weight - 1].pack(FORMAT)
end
weight=(value) click to toggle source
Calls superclass method
# File lib/protocol/http2/priority_frame.rb, line 56
def weight= value
        if VALID_WEIGHT.include?(value)
                super
        else
                raise ArgumentError, "Weight #{value} must be between 1-256!"
        end
end