Class: Protocol::HTTP2::SettingsFrame

Inherits:
Frame
  • Object
show all
Includes:
Acknowledgement
Defined in:
lib/protocol/http2/settings_frame.rb

Overview

The SETTINGS frame conveys configuration parameters that affect how endpoints communicate, such as preferences and constraints on peer behavior. The SETTINGS frame is also used to acknowledge the receipt of those parameters. Individually, a SETTINGS parameter can also be referred to as a “setting”.

------------------------------- | Identifier (16) | -------------------------------——————————-+ | Value (32) | ---------------------------------------------------------------

Constant Summary collapse

TYPE =
0x4
FORMAT =
"nN".freeze

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 inherited from Frame

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

Instance Method Summary collapse

Methods included from Acknowledgement

#acknowledge, #acknowledgement?

Methods inherited from Frame

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

Constructor Details

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

Instance Method Details

#apply(connection) ⇒ Object



241
242
243
# File 'lib/protocol/http2/settings_frame.rb', line 241

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

#connection?Boolean

Returns:

  • (Boolean)


229
230
231
# File 'lib/protocol/http2/settings_frame.rb', line 229

def connection?
	true
end

#pack(settings = []) ⇒ Object



237
238
239
# File 'lib/protocol/http2/settings_frame.rb', line 237

def pack(settings = [])
	super settings.map{|s| s.pack(FORMAT)}.join
end

#read_payload(stream) ⇒ Object



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/protocol/http2/settings_frame.rb', line 245

def read_payload(stream)
	super
	
	if @stream_id != 0
		raise ProtocolError, "Settings apply to connection only, but stream_id was given"
	end
	
	if acknowledgement? and @length != 0
		raise FrameSizeError, "Settings acknowledgement must not contain payload: #{@payload.inspect}"
	end
	
	if (@length % 6) != 0
		raise FrameSizeError, "Invalid frame length"
	end
end

#unpackObject



233
234
235
# File 'lib/protocol/http2/settings_frame.rb', line 233

def unpack
	super.scan(/....../).map{|s| s.unpack(FORMAT)}
end