Class: HTTP2::Settings

Inherits:
Struct
  • Object
show all
Defined in:
sig/settings.rbs,
lib/http/2/settings.rb

Overview

Container for all settings required for the management of an HTTP/2 connection. This includes the managemenet of the settings negotiated via the SETTINGS frame, as well as user-level configuration related with header compression.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings_header_table_size: MAX_HEADER_TABLE_SIZE, settings_enable_push: 1, settings_max_concurrent_streams: 100, settings_initial_window_size: 65_535, settings_max_frame_size: 16_384, settings_max_header_list_size: MAX_HEADER_LIST_SIZE, huffman: :shorter, index: :all, table_size: MAX_HEADER_TABLE_SIZE) ⇒ Settings

Returns a new instance of Settings.

Parameters:

  • settings_header_table_size: (Integer) (defaults to: MAX_HEADER_TABLE_SIZE)
  • settings_enable_push: (Integer) (defaults to: 1)
  • settings_max_concurrent_streams: (Integer) (defaults to: 100)
  • settings_initial_window_size: (Integer) (defaults to: 65_535)
  • settings_max_frame_size: (Integer) (defaults to: 16_384)
  • settings_max_header_list_size: (Integer) (defaults to: MAX_HEADER_LIST_SIZE)
  • huffman: (huffman_type) (defaults to: :shorter)
  • index: (index_type) (defaults to: :all)
  • table_size: (Integer) (defaults to: MAX_HEADER_TABLE_SIZE)


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/http/2/settings.rb', line 33

def initialize(
  # connection settings
  settings_header_table_size: MAX_HEADER_TABLE_SIZE,
  settings_enable_push: 1,
  settings_max_concurrent_streams: 100,
  settings_initial_window_size: 65_535,
  settings_max_frame_size: 16_384,
  settings_max_header_list_size: MAX_HEADER_LIST_SIZE,
  # encoding context settings
  huffman: :shorter,
  index: :all,
  table_size: MAX_HEADER_TABLE_SIZE
)
  super
end

Instance Attribute Details

#huffman ⇒ huffman_type

controls how to use huffman encoding to encode strings. can be one of the following values:

  • :always - Always use Huffman encoding
  • :never - Do not use Huffman encoding
  • :shorter - Use Huffman when the result is strictly shorter

Returns:

  • (huffman_type)


43
44
45
# File 'sig/settings.rbs', line 43

def huffman
  @huffman
end

#index ⇒ index_type

controls the configuration of the HPACK indexing tables:

  • :static - use the static table only
  • :all - use the static table and the dynamic table
  • :never - do not use any of the tables.

Returns:

  • (index_type)


50
51
52
# File 'sig/settings.rbs', line 50

def index
  @index
end

#settings_enable_push ⇒ Integer

can be used to disable server push (set to 0)

Returns:

  • (Integer)


24
25
26
# File 'sig/settings.rbs', line 24

def settings_enable_push
  @settings_enable_push
end

#settings_header_table_size ⇒ Integer

maximum size of the header compression table used to decode header blocks, in bytes.

Returns:

  • (Integer)


21
22
23
# File 'sig/settings.rbs', line 21

def settings_header_table_size
  @settings_header_table_size
end

#settings_initial_window_size ⇒ Integer

initial window size (in bytes) for stream-level flow control.

Returns:

  • (Integer)


30
31
32
# File 'sig/settings.rbs', line 30

def settings_initial_window_size
  @settings_initial_window_size
end

#settings_max_concurrent_streams ⇒ Integer

maximum number of concurrent streams that the sender will allow.

Returns:

  • (Integer)


27
28
29
# File 'sig/settings.rbs', line 27

def settings_max_concurrent_streams
  @settings_max_concurrent_streams
end

#settings_max_frame_size ⇒ Integer

max size of for payload that the sender is willing to receive, in bytes.

Returns:

  • (Integer)


33
34
35
# File 'sig/settings.rbs', line 33

def settings_max_frame_size
  @settings_max_frame_size
end

#settings_max_header_list_size ⇒ Object

Returns the value of attribute settings_max_header_list_size

Returns:

  • (Object) —

    the current value of settings_max_header_list_size



19
20
21
# File 'lib/http/2/settings.rb', line 19

def settings_max_header_list_size
  @settings_max_header_list_size
end

#table_size ⇒ Integer

maximum dynamic table size in bytes

Returns:

  • (Integer)


53
54
55
# File 'sig/settings.rbs', line 53

def table_size
  @table_size
end

Instance Method Details

#connection_settings ⇒ self #connection_settings ⇒ Enumerable[[Symbol, Integer]]

yields connection-level settings only.

Overloads:

  • #connection_settings ⇒ self

    Returns:

    • (self)
  • #connection_settings ⇒ Enumerable[[Symbol, Integer]]

    Returns:

    • (Enumerable[[Symbol, Integer]])

Yields:

Yield Parameters:

  • arg0 (Symbol)
  • arg1 (Integer)

Yield Returns:

  • (void)


70
71
72
73
74
75
76
77
78
# File 'sig/settings.rbs', line 70

def connection_settings
  return enum_for(__method__) unless block_given?

  each_pair do |k, v|
    next if ENCODING_CONTEXT_SETTINGS.include?(k)

    yield k, v
  end
end