module Rack::Request::Env

def add_header(key, v)

http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

assert_equal 'image/png,*/*', request.get_header('Accept')

request.add_header 'Accept', '*/*'
request.add_header 'Accept', 'image/png'
Example:

Add a header that may have multiple values.
def add_header(key, v)
  if v.nil?
    get_header key
  elsif has_header? key
    set_header key, "#{get_header key},#{v}"
  else
    set_header key, v
  end
end

def delete_header(name)

Delete a request specific value for `name`.
def delete_header(name)
  @env.delete name
end

def each_header(&block)

Loops through each key / value pair in the request specific data.
def each_header(&block)
  @env.each(&block)
end

def fetch_header(name, &block)

on the request.
If a block is given, it yields to the block if the value hasn't been set
def fetch_header(name, &block)
  @env.fetch(name, &block)
end

def get_header(name)

Get a request specific value for `name`.
def get_header(name)
  @env[name]
end

def has_header?(name)

specific data
Predicate method to test to see if `name` has been set as request
def has_header?(name)
  @env.key? name
end

def initialize(env)

def initialize(env)
  @env = env
  # This module is included at least in `ActionDispatch::Request`
  # The call to `super()` allows additional mixed-in initializers are called
  super()
end

def initialize_copy(other)

def initialize_copy(other)
  @env = other.env.dup
end

def set_header(name, v)

Set a request specific value for `name` to `v`
def set_header(name, v)
  @env[name] = v
end