Class: Baykit::BayServer::Docker::Http::H2::HeaderBlockBuilder

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

Instance Method Summary collapse

Instance Method Details

#build_header_block(name, value, tbl) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/baykit/bayserver/docker/http/h2/header_block_builder.rb', line 8

def build_header_block(name, value, tbl)
  idx_list = tbl.get_idx_list(name)
  blk = nil

  idx_list.each do |idx|
    kv = tbl.get(idx)
    if kv != nil && value == kv.value
      blk = HeaderBlock.new
      blk.op = HeaderBlock::INDEX
      blk.index = idx
      break
    end
  end

  if blk == nil
    blk = HeaderBlock.new()
    if idx_list.length > 0
      blk.op = HeaderBlock::KNOWN_HEADER
      blk.index = idx_list[0]
      blk.value = value
    else
      blk.op = HeaderBlock::UNKNOWN_HEADER
      blk.name = name
      blk.value = value
    end
  end

  return blk
end

#build_status_block(status, tbl) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/baykit/bayserver/docker/http/h2/header_block_builder.rb', line 38

def build_status_block(status, tbl)
  st_index = -1

  status_index_list = tbl.get(":status")
  status_index_list.each do |index|
    kv = tbl.get(index)
    if kv != nil && status == kv.value.to_i
      st_index = index
      break
    end
  end

  blk = HeaderBlock.new()
  if st_index == -1
    blk.op = HeaderBlock::INDEX
    blk.index = st_index
  else
    blk.op = HeaderBlock::KNOWN_HEADER
    blk.index = status_index_list[0]
    blk.value = status.to_i
  end

  return blk
end