Class: HTTP::Protocol::HTTP2::HeadersFrame

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

Overview

The HEADERS frame is used to open a stream, and additionally carries a header block fragment. HEADERS frames can be sent on a stream in the “idle”, “reserved (local)”, “open”, or “half-closed (remote)” state.

--------------- |Pad Length? (8)| -————------------------------------------------------ |E| Stream Dependency? (31) | -————------------------------------------------------ | Weight? (8) | -————------------------------------------------------ | Header Block Fragment (*) … --------------------------------------------------------------- | Padding (*) … ---------------------------------------------------------------

Constant Summary collapse

TYPE =
0x1

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

#end_headers?, #initialize, #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

Instance Method Details

#apply(connection) ⇒ Object



79
80
81
# File 'lib/http/protocol/http2/headers_frame.rb', line 79

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

#end_stream?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/http/protocol/http2/headers_frame.rb', line 52

def end_stream?
	flag_set?(END_STREAM)
end

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



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/http/protocol/http2/headers_frame.rb', line 67

def pack(priority, data, *args)
	buffer = String.new.b
	
	if priority
		buffer << priority.pack
	end
	
	buffer << data
	
	super(buffer, *args)
end

#priority?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/http/protocol/http2/headers_frame.rb', line 48

def priority?
	flag_set?(PRIORITY)
end

#unpackObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/http/protocol/http2/headers_frame.rb', line 56

def unpack
	data = super
	
	if priority?
		priority = Priority.unpack(data)
		data = data.byteslice(5, data.bytesize - 5)
	end
	
	return priority, data
end