Class: HTTP::Protocol::HTTP2::PushPromiseFrame

Inherits:
Frame
  • Object
show all
Includes:
Continued, Padded
Defined in:
lib/http/protocol/http2/push_promise_frame.rb

Overview

The PUSH_PROMISE frame is used to notify the peer endpoint in advance of streams the sender intends to initiate. The PUSH_PROMISE frame includes the unsigned 31-bit identifier of the stream the endpoint plans to create along with a set of headers that provide additional context for the stream.

--------------- |Pad Length? (8)| -————------------------------------------------------ |R| Promised Stream ID (31) | -—————————–------------------------------- | Header Block Fragment (*) … --------------------------------------------------------------- | Padding (*) … ---------------------------------------------------------------

Constant Summary collapse

TYPE =
0x5
FORMAT =
"N".freeze

Constants included from Padded

HTTP::Protocol::HTTP2::Padded::MODULUS

Constants inherited from Frame

Frame::HEADER_FORMAT, Frame::LENGTH_HISHIFT, Frame::LENGTH_LOMASK, Frame::STREAM_ID_MASK, Frame::VALID_LENGTH, Frame::VALID_STREAM_ID

Instance Attribute Summary

Attributes included from Continued

#continuation

Attributes inherited from Frame

#flags, #length, #payload, #stream_id, #type

Instance Method Summary collapse

Methods included from Continued

#read, #write

Methods included from Padded

#padded?

Methods inherited from Frame

#<=>, #clear_flags, #connection?, #flag_set?, #header, #initialize, parse_header, #read, #read_header, #read_payload, #set_flags, #to_ary, #write, #write_header, #write_payload

Constructor Details

This class inherits a constructor from HTTP::Protocol::HTTP2::Frame

Instance Method Details

#apply(connection) ⇒ Object



61
62
63
# File 'lib/http/protocol/http2/push_promise_frame.rb', line 61

def apply(connection)
	connection.receive_push_promise(self)
end

#end_headers?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/http/protocol/http2/push_promise_frame.rb', line 45

def end_headers?
	flag_set?(END_HEADERS)
end

#pack(stream_id, data, *args) ⇒ Object



57
58
59
# File 'lib/http/protocol/http2/push_promise_frame.rb', line 57

def pack(stream_id, data, *args)
	super([stream_id].pack(FORMAT) + data, *args)
end

#unpackObject



49
50
51
52
53
54
55
# File 'lib/http/protocol/http2/push_promise_frame.rb', line 49

def unpack
	data = super
	
	stream_id = data.unpack(FORMAT).first
	
	return stream_id, data.byteslice(4, data.bytesize - 4)
end