module Aws::Xray::HeaderParser

Public Instance Methods

delim?(c) click to toggle source
# File lib/aws/xray/header_parser.rb, line 40
def delim?(c)
  c == ';'
end
equal_mark?(c) click to toggle source
# File lib/aws/xray/header_parser.rb, line 44
def equal_mark?(c)
  c == '='
end
parse(header_value) click to toggle source

Header format document: docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader

# File lib/aws/xray/header_parser.rb, line 7
def parse(header_value)
  h = {}
  key = ''
  value = ''
  value_mode = false
  header_value.chars.each_with_index do |c, i|
    next if space?(c)
    if delim?(c)
      h[key] = value unless key.empty?
      key, value = '', ''
      value_mode = false
      next
    end

    if equal_mark?(c)
      value_mode = true
      next
    end

    if value_mode
      value << c
    else
      key << c
    end
  end
  h[key] = value if !key.empty? && !value.empty?
  h
end
space?(c) click to toggle source
# File lib/aws/xray/header_parser.rb, line 36
def space?(c)
  c == ' '
end