Class: Puma::Util::HeaderHash

### Home Classes Methods

### In Files

- lib/puma/util.rb

### Parent

Hash

### Methods

- ::new
- ::new
- #[]
- #[]=
- #delete
- #each
- #has_key?
- #include?
- #key?
- #member?
- #merge
- #merge!
- #replace
- #to_hash

### Files

- Manifest.txt

### Class/Module Index

Quicksearch

- Puma
- Puma::App
- Puma::App::Status
- Puma::Binder
- Puma::CLI
- Puma::Client
- Puma::Cluster
- Puma::Cluster::Worker
- Puma::CommonLogger
- Puma::ConfigDefault
- Puma::Configuration
- Puma::Configuration::ConfigMiddleware
- Puma::ConnectionError
- Puma::Const
- Puma::ControlCLI
- Puma::DSL
- Puma::Delegation
- Puma::Events
- Puma::Events::DefaultFormatter
- Puma::Events::PidFormatter
- Puma::IOBuffer
- Puma::JRubyRestart
- Puma::JavaIOBuffer
- Puma::MiniSSL
- Puma::MiniSSL::Context
- Puma::MiniSSL::SSLError
- Puma::MiniSSL::Server
- Puma::MiniSSL::Socket
- Puma::NullIO
- Puma::Rack
- Puma::Rack::Builder
- Puma::Rack::Options
- Puma::Rack::URLMap
- Puma::Reactor
- Puma::Runner
- Puma::Server
- Puma::Single
- Puma::TCPLogger
- Puma::ThreadPool
- Puma::ThreadPool::AutoTrim
- Puma::ThreadPool::Reaper
- Puma::UnsupportedOption
- Puma::Util
- Puma::Util::HeaderHash
- OpenSSL
- OpenSSL::SSL
- OpenSSL::SSL::SSLServer
- Rack
- Rack::Handler
- Rack::Handler::Puma
- IO
- IO::WaitReadable
- Object
- Process
- String

No matching classes.

# Puma::Util::HeaderHash

A case-insensitive Hash that preserves the original case of a header when set.

### Public Class Methods

new(hash={}) click to toggle source

    # File lib/puma/util.rb, line 67
    def self.new(hash={})
      HeaderHash === hash ? hash : super(hash)
    end

new(hash={}) click to toggle source

    # File lib/puma/util.rb, line 71
    def initialize(hash={})
      super()
      @names = {}
      hash.each { |k, v| self[k] = v }
    end

### Public Instance Methods

[](k) click to toggle source

    # File lib/puma/util.rb, line 89
    def [](k)
      super(k) || super(@names[k.downcase])
    end

[]=(k, v) click to toggle source

    # File lib/puma/util.rb, line 93
    def []=(k, v)
      canonical = k.downcase
      delete k if @names[canonical] && @names[canonical] != k # .delete is expensive, don't invoke it unless necessary
      @names[k] = @names[canonical] = k
      super k, v
    end

delete(k) click to toggle source

    # File lib/puma/util.rb, line 100
    def delete(k)
      canonical = k.downcase
      result = super @names.delete(canonical)
      @names.delete_if { |name,| name.downcase == canonical }
      result
    end

each() click to toggle source

    # File lib/puma/util.rb, line 77
    def each
      super do |k, v|
        yield(k, v.respond_to?(:to_ary) ? v.to_ary.join("\n") : v)
      end
    end

has_key?(k) click to toggle source
Alias for: include?
include?(k) click to toggle source

    # File lib/puma/util.rb, line 107
    def include?(k)
      @names.include?(k) || @names.include?(k.downcase)
    end

Also aliased as: has_key?, member?, key?
key?(k) click to toggle source
Alias for: include?
member?(k) click to toggle source
Alias for: include?
merge(other) click to toggle source

    # File lib/puma/util.rb, line 120
    def merge(other)
      hash = dup
      hash.merge! other
    end

merge!(other) click to toggle source

    # File lib/puma/util.rb, line 115
    def merge!(other)
      other.each { |k, v| self[k] = v }
      self
    end

replace(other) click to toggle source

    # File lib/puma/util.rb, line 125
    def replace(other)
      clear
      other.each { |k, v| self[k] = v }
      self
    end

to_hash() click to toggle source

    # File lib/puma/util.rb, line 83
    def to_hash
      hash = {}
      each { |k,v| hash[k] = v }
      hash
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.