Class: Protocol::HTTP2::Settings

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

Overview

HTTP/2 connection settings container and management.

Constant Summary collapse

HEADER_TABLE_SIZE =
0x1
ENABLE_PUSH =
0x2
MAXIMUM_CONCURRENT_STREAMS =
0x3
INITIAL_WINDOW_SIZE =
0x4
MAXIMUM_FRAME_SIZE =
0x5
MAXIMUM_HEADER_LIST_SIZE =
0x6
ENABLE_CONNECT_PROTOCOL =
0x8
NO_RFC7540_PRIORITIES =
0x9
ASSIGN =
[
	nil,
	:header_table_size=,
	:enable_push=,
	:maximum_concurrent_streams=,
	:initial_window_size=,
	:maximum_frame_size=,
	:maximum_header_list_size=,
	nil,
	:enable_connect_protocol=,
	:no_rfc7540_priorities=,
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSettings

Initialize settings with default values from HTTP/2 specification.



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/protocol/http2/settings_frame.rb', line 35

def initialize
	# These limits are taken from the RFC:
	# https://tools.ietf.org/html/rfc7540#section-6.5.2
	@header_table_size = 4096
	@enable_push = 1
	@maximum_concurrent_streams = 0xFFFFFFFF
	@initial_window_size = 0xFFFF # 2**16 - 1
	@maximum_frame_size = 0x4000 # 2**14
	@maximum_header_list_size = 0xFFFFFFFF
	@enable_connect_protocol = 0
	@no_rfc7540_priorities = 0
end

Instance Attribute Details

#enable_connect_protocolObject

Returns the value of attribute enable_connect_protocol.



107
108
109
# File 'lib/protocol/http2/settings_frame.rb', line 107

def enable_connect_protocol
  @enable_connect_protocol
end

#enable_pushObject

This setting can be used to disable server push. An endpoint MUST NOT send a PUSH_PROMISE frame if it receives this parameter set to a value of 0.



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

def enable_push
  @enable_push
end

#header_table_sizeObject

Allows the sender to inform the remote endpoint of the maximum size of the header compression table used to decode header blocks, in octets.



49
50
51
# File 'lib/protocol/http2/settings_frame.rb', line 49

def header_table_size
  @header_table_size
end

#initial_window_sizeObject

Indicates the sender’s initial window size (in octets) for stream-level flow control.



75
76
77
# File 'lib/protocol/http2/settings_frame.rb', line 75

def initial_window_size
  @initial_window_size
end

#maximum_concurrent_streamsObject

Indicates the maximum number of concurrent streams that the sender will allow.



72
73
74
# File 'lib/protocol/http2/settings_frame.rb', line 72

def maximum_concurrent_streams
  @maximum_concurrent_streams
end

#maximum_frame_sizeObject

Indicates the size of the largest frame payload that the sender is willing to receive, in octets.



89
90
91
# File 'lib/protocol/http2/settings_frame.rb', line 89

def maximum_frame_size
  @maximum_frame_size
end

#maximum_header_list_sizeObject

This advisory setting informs a peer of the maximum size of header list that the sender is prepared to accept, in octets.



105
106
107
# File 'lib/protocol/http2/settings_frame.rb', line 105

def maximum_header_list_size
  @maximum_header_list_size
end

#no_rfc7540_prioritiesObject

Returns the value of attribute no_rfc7540_priorities.



126
127
128
# File 'lib/protocol/http2/settings_frame.rb', line 126

def no_rfc7540_priorities
  @no_rfc7540_priorities
end

Instance Method Details

#enable_connect_protocol?Boolean

Check if CONNECT protocol is enabled.

Returns:

  • (Boolean)


122
123
124
# File 'lib/protocol/http2/settings_frame.rb', line 122

def enable_connect_protocol?
	@enable_connect_protocol == 1
end

#enable_push?Boolean

Check if server push is enabled.

Returns:

  • (Boolean)


67
68
69
# File 'lib/protocol/http2/settings_frame.rb', line 67

def enable_push?
	@enable_push == 1
end

#no_rfc7540_priorities?Boolean

Check if RFC 7540 priorities are disabled.

Returns:

  • (Boolean)


141
142
143
# File 'lib/protocol/http2/settings_frame.rb', line 141

def no_rfc7540_priorities?
	@no_rfc7540_priorities == 1
end

#update(changes) ⇒ Object

Update settings with a hash of changes.



147
148
149
150
151
152
153
# File 'lib/protocol/http2/settings_frame.rb', line 147

def update(changes)
	changes.each do |key, value|
		if name = ASSIGN[key]
			self.send(name, value)
		end
	end
end