Class: Rack::Utils::HeaderHash

### Home Classes Methods

### In Files

- lib/rack/utils.rb

### Parent

Hash

### Methods

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

### Files

- KNOWN-ISSUES
- README
- SPEC

### Class/Module Index

Quicksearch

- Rack
- Rack::Auth
- Rack::Auth::AbstractHandler
- Rack::Auth::AbstractRequest
- Rack::Auth::Basic
- Rack::Auth::Basic::Request
- Rack::Auth::Digest
- Rack::Auth::Digest::MD5
- Rack::Auth::Digest::Nonce
- Rack::Auth::Digest::Params
- Rack::Auth::Digest::Request
- Rack::Builder
- Rack::Cascade
- Rack::Chunked
- Rack::CommonLogger
- Rack::ConditionalGet
- Rack::Config
- Rack::ContentLength
- Rack::ContentType
- Rack::Deflater
- Rack::Deflater::DeflateStream
- Rack::Deflater::GzipStream
- Rack::Directory
- Rack::ETag
- Rack::File
- Rack::ForwardRequest
- Rack::Handler
- Rack::Handler::CGI
- Rack::Handler::EventedMongrel
- Rack::Handler::FastCGI
- Rack::Handler::LSWS
- Rack::Handler::Mongrel
- Rack::Handler::SCGI
- Rack::Handler::SwiftipliedMongrel
- Rack::Handler::Thin
- Rack::Handler::WEBrick
- Rack::Head
- Rack::Lint
- Rack::Lobster
- Rack::Lock
- Rack::Logger
- Rack::MethodOverride
- Rack::Mime
- Rack::MockRequest
- Rack::MockRequest::FatalWarner
- Rack::MockRequest::FatalWarning
- Rack::MockResponse
- Rack::NullLogger
- Rack::Recursive
- Rack::Reloader
- Rack::Reloader::Stat
- Rack::Request
- Rack::Response
- Rack::Response::Helpers
- Rack::RewindableInput
- Rack::RewindableInput::Tempfile
- Rack::Runtime
- Rack::Sendfile
- Rack::Server
- Rack::Server::Options
- Rack::Session
- Rack::Session::Abstract
- Rack::Session::Abstract::ID
- Rack::Session::Cookie
- Rack::Session::Memcache
- Rack::Session::Pool
- Rack::ShowExceptions
- Rack::ShowStatus
- Rack::Static
- Rack::URLMap
- Rack::Utils
- Rack::Utils::Context
- Rack::Utils::HeaderHash
- Rack::Utils::Multipart
- Rack::Utils::Multipart::UploadedFile
- FCGI
- FCGI::Stream

No matching classes.

# Rack::Utils::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/rack/utils.rb, line 292
    def self.new(hash={})
      HeaderHash === hash ? hash : super(hash)
    end

new(hash={}) click to toggle source

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

### Public Instance Methods

[](k) click to toggle source

    # File lib/rack/utils.rb, line 319
    def [](k)
      super(@names[k]) if @names[k]
      super(@names[k.downcase])
    end

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

    # File lib/rack/utils.rb, line 324
    def []=(k, v)
      delete k
      @names[k] = @names[k.downcase] = k
      super k, v
    end

delete(k) click to toggle source

    # File lib/rack/utils.rb, line 330
    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/rack/utils.rb, line 302
    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/rack/utils.rb, line 337
    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/rack/utils.rb, line 350
    def merge(other)
      hash = dup
      hash.merge! other
    end

merge!(other) click to toggle source

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

replace(other) click to toggle source

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

to_hash() click to toggle source

    # File lib/rack/utils.rb, line 308
    def to_hash
      inject({}) do |hash, (k,v)|
        if v.respond_to? :to_ary
          hash[k] = v.to_ary.join("\n")
        else
          hash[k] = v
        end
        hash
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.