class Async::HTTP::Headers
def == other
def == other if other.is_a? Hash to_h == other else @fields == other.fields end end
def [] key
def [] key @indexed ||= to_h @indexed[key] end
def []= key, value
def []= key, value @fields << [key, value] if @indexed key = key.downcase if current_value = @indexed[key] @indexed[key] = Array(current_value) << value else @indexed[key] = value end end end
def delete(key)
def delete(key) values, @fields = @fields.partition do |field| field.first.downcase == key end if @indexed @indexed.delete(key) end if field = values.last return field.last end end
def each(&block)
def each(&block) @fields.each(&block) end
def freeze
def freeze return if frozen? @indexed = to_h super end
def include? key
def include? key self[key] != nil end
def initialize(fields = [])
def initialize(fields = []) @fields = fields @indexed = to_h end
def to_h
def to_h @fields.inject({}) do |hash, (key, value)| key = key.downcase if current_value = hash[key] hash[key] = Array(current_value) << value else hash[key] = value end hash end end