Method: HTTP::Protocol::HTTP2::Frame#header

Defined in:
lib/http/protocol/http2/frame.rb

#headerString

Generates common 9-byte frame header.

Returns:

  • (String)


121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/http/protocol/http2/frame.rb', line 121

def header
	unless VALID_LENGTH.include? @length
		raise ProtocolError, "Invalid frame size: #{@length.inspect}"
	end
	
	unless VALID_STREAM_ID.include? @stream_id
		raise ProtocolError, "Invalid stream identifier: #{@stream_id.inspect}"
	end
	
	[
		# These are guaranteed correct due to the length check above.
		@length >> LENGTH_HISHIFT,
		@length & LENGTH_LOMASK,
		@type,
		@flags,
		@stream_id
	].pack(HEADER_FORMAT)
end