# module Rack::Request::Env

### Attributes

env[R]

The environment of the request.

### Public Class Methods

new(env) click to toggle source
Calls superclass method

    # File lib/rack/request.rb, line 50
    def initialize(env)
      @env = env
      super()
    end

### Public Instance Methods

add_header(key, v) click to toggle source

Add a header that may have multiple values.

Example:

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

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

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

    # File lib/rack/request.rb, line 91
    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

delete_header(name) click to toggle source

Delete a request specific value for `name`.

    # File lib/rack/request.rb, line 102
    def delete_header(name)
      @env.delete name
    end

each_header(&block) click to toggle source

Loops through each key / value pair in the request specific data.

    # File lib/rack/request.rb, line 73
    def each_header(&block)
      @env.each(&block)
    end

fetch_header(name, &block) click to toggle source

If a block is given, it yields to the block if the value hasn't been set on the request.

    # File lib/rack/request.rb, line 68
    def fetch_header(name, &block)
      @env.fetch(name, &block)
    end

get_header(name) click to toggle source

Get a request specific value for `name`.

    # File lib/rack/request.rb, line 62
    def get_header(name)
      @env[name]
    end

has_header?(name) click to toggle source

Predicate method to test to see if `name` has been set as request specific data

    # File lib/rack/request.rb, line 57
    def has_header?(name)
      @env.key? name
    end

initialize_copy(other) click to toggle source

    # File lib/rack/request.rb, line 106
    def initialize_copy(other)
      @env = other.env.dup
    end

set_header(name, v) click to toggle source

Set a request specific value for `name` to `v`

    # File lib/rack/request.rb, line 78
    def set_header(name, v)
      @env[name] = v
    end