Module: Aws::Xray::HeaderParser
Instance Method Summary collapse
- #delim?(c) ⇒ Boolean
- #equal_mark?(c) ⇒ Boolean
-
#parse(header_value) ⇒ Object
Header format document: docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader.
- #space?(c) ⇒ Boolean
Instance Method Details
#delim?(c) ⇒ Boolean
40 41 42 |
# File 'lib/aws/xray/header_parser.rb', line 40 def delim?(c) c == ';' end |
#equal_mark?(c) ⇒ Boolean
44 45 46 |
# File 'lib/aws/xray/header_parser.rb', line 44 def equal_mark?(c) c == '=' end |
#parse(header_value) ⇒ Object
Header format document: docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader
7 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 |
# 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) ⇒ Boolean
36 37 38 |
# File 'lib/aws/xray/header_parser.rb', line 36 def space?(c) c == ' ' end |