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!, #acknowledgement?

Methods inherited from Frame

#<=>, #clear_flags, #flag_set?, #header, #initialize, #inspect, 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



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

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

#connection?Boolean

Returns:

  • (Boolean)


217
218
219
# File 'lib/protocol/http2/settings_frame.rb', line 217

def connection?
	true
end

#pack(settings = []) ⇒ Object



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

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

#read_payload(stream) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/protocol/http2/settings_frame.rb', line 238

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



221
222
223
224
225
226
227
228
# File 'lib/protocol/http2/settings_frame.rb', line 221

def unpack
	if buffer = super
		# TODO String#each_slice, or #each_unpack would be nice.
		buffer.scan(/....../m).map{|s| s.unpack(FORMAT)}
	else
		[]
	end
end