Sha256: d5486d437e4fee82cf1a956d6889c4cb8a7b16c41a9af26b60f29a42ac00a992
Contents?: true
Size: 1.06 KB
Versions: 65
Compression:
Stored size: 1.06 KB
Contents
module Flexirest class HeadersList STORE_MULTIPLE_VALUES = ["set-cookie"] def initialize @store = {} end def []=(key,value) key = find_existing(key) if STORE_MULTIPLE_VALUES.include?(key.downcase) @store[key] ||= [] @store[key] << value else @store[key] = value end end def [](key) key = find_existing(key) @store[key] end def each(split_multiple_headers = false) @store.keys.each do |key| value = @store[key] if value.is_a?(Array) && split_multiple_headers value.each do |inner_value| yield(key, inner_value) end else yield(key, value) end end end def delete(key) key = find_existing(key) @store.delete(key) end def keys @store.keys end private def find_existing(key) key_downcase = key.downcase @store.keys.each do |found_key| return found_key if found_key.downcase == key_downcase end key end end end
Version data entries
65 entries across 65 versions & 1 rubygems