class Faraday::Utils::Headers
def [](k)
def [](k) super(KeyMap[k]) end
def []=(k, v)
def []=(k, v) # join multiple values with a comma v = v.to_ary.join(', ') if v.respond_to? :to_ary super(KeyMap[k], v) end
def parse(header_string)
def parse(header_string) return unless header_string && !header_string.empty? header_string.split(/\r\n/). tap { |a| a.shift if a.first.index('HTTP/') == 0 }. # drop the HTTP status line map { |h| h.split(/:\s+/, 2) }.reject { |(k, v)| k.nil? }. # split key and value, ignore blank lines each { |key, value| # join multiple values with a comma if self[key] then self[key] << ', ' << value else self[key] = value end } end