Class: Baykit::BayServer::Docker::Http::H2::HeaderTable

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/baykit/bayserver/docker/http/h2/header_table.rb

Constant Summary collapse

PSEUDO_HEADER_AUTHORITY =
":authority"
PSEUDO_HEADER_METHOD =
":method"
PSEUDO_HEADER_PATH =
":path"
PSEUDO_HEADER_SCHEME =
":scheme"
PSEUDO_HEADER_STATUS =
":status"

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHeaderTable

Returns a new instance of HeaderTable.



21
22
23
24
25
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 21

def initialize
  @idx_map = []
  @add_count = 0
  @name_map = {}
end

Class Attribute Details

.static_sizeObject (readonly)

Returns the value of attribute static_size.



92
93
94
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 92

def static_size
  @static_size
end

.static_tableObject (readonly)

Returns the value of attribute static_table.



91
92
93
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 91

def static_table
  @static_table
end

Instance Attribute Details

#add_countObject (readonly)

Returns the value of attribute add_count.



18
19
20
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 18

def add_count
  @add_count
end

#idx_mapObject (readonly)

Returns the value of attribute idx_map.



17
18
19
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 17

def idx_map
  @idx_map
end

#name_mapObject (readonly)

Returns the value of attribute name_map.



19
20
21
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 19

def name_map
  @name_map
end

Instance Method Details

#get(idx) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 27

def get(idx)
  if idx <= 0 || idx > HeaderTable.static_size + @idx_map.length
    raise RuntimeError "idx=#{idx} static=#{HeaderTable.static_size} dynamic=#{@idx_map.length}"
  end

  if idx <= HeaderTable.static_size
    kv = HeaderTable.static_table.idx_map[idx - 1]
  else
    kv = @idx_map[(idx - HeaderTable.static_size) - 1]
  end
  kv
end

#get_idx_list(name) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 40

def get_idx_list(name)
  dynamic_list = @name_map[name]
  static_list = HeaderTable.static_table.name_map[name]

  idx_list = []
  if static_list != nil
    idx_list.concat static_list
  end
  if dynamic_list != nil
    dynamic_list.each do |idx|
      real_index = @add_count - idx + HeaderTable.static_size
      idx_list << real_index
    end
  end
  return idx_list
end

#insert(name, value) ⇒ Object



57
58
59
60
61
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 57

def insert(name, value)
  @idx_map.insert(0, KeyVal.new(name, value))
  @add_count += 1
  add_to_name_map(name, @add_count)
end

#put(idx, name, value) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 67

def put(idx, name, value)
  if idx != @idx_map.length + 1
    raise RuntimeError.new("Illegal State")
  end
  @idx_map.append(KeyVal.new(name, value))
  add_to_name_map(name, idx)
end

#set_size(size) ⇒ Object



63
64
65
# File 'lib/baykit/bayserver/docker/http/h2/header_table.rb', line 63

def set_size(size)

end