class ActionDispatch::Http::Headers

headers # => “text/plain”
headers = ActionDispatch::Http::Headers.new(env)
env = { “CONTENT_TYPE” => “text/plain” }
Provides access to the request’s HTTP headers from the environment.

def [](key)

Returns the value for the given key mapped to @env.
def [](key)
  @env[env_name(key)]
end

def []=(key, value)

Sets the given value for the key mapped to @env.
def []=(key, value)
  @env[env_name(key)] = value
end

def each(&block)

def each(&block)
  @env.each(&block)
end

def env_name(key)

not contained within the headers hash.
Converts a HTTP header name to an environment variable name if it is
def env_name(key)
  key = key.to_s
  if key =~ HTTP_HEADER
    key = key.upcase.tr('-', '_')
    key = "HTTP_" + key unless CGI_VARIABLES.include?(key)
  end
  key
end

def fetch(key, *args, &block)

its result returned.
If the code block is provided, then it will be run and

raises a KeyError exception.
If the key is not found and an optional code block is not provided,

Returns the value for the given key mapped to @env.
def fetch(key, *args, &block)
  @env.fetch env_name(key), *args, &block
end

def initialize(env = {}) # :nodoc:

:nodoc:
def initialize(env = {}) # :nodoc:
  @env = env
end

def key?(key)

def key?(key)
  @env.key? env_name(key)
end

def merge(headers_or_env)

headers_or_env and the original instance.
Returns a new Http::Headers instance containing the contents of
def merge(headers_or_env)
  headers = Http::Headers.new(env.dup)
  headers.merge!(headers_or_env)
  headers
end

def merge!(headers_or_env)

headers_or_env.
entries; duplicate keys are overwritten with the values from
Adds the contents of headers_or_env to original instance
def merge!(headers_or_env)
  headers_or_env.each do |key, value|
    self[env_name(key)] = value
  end
end