module Rack::Request::Env
Attributes
The environment of the request.
Public Class Methods
Source
# File lib/rack/request.rb, line 91 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
Calls superclass method
Public Instance Methods
Source
# File lib/rack/request.rb, line 134 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
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')
Source
# File lib/rack/request.rb, line 145 def delete_header(name) @env.delete name end
Delete a request specific value for ‘name`.
Source
# File lib/rack/request.rb, line 116 def each_header(&block) @env.each(&block) end
Loops through each key / value pair in the request specific data.
Source
# File lib/rack/request.rb, line 111 def fetch_header(name, &block) @env.fetch(name, &block) end
If a block is given, it yields to the block if the value hasn’t been set on the request.
Source
# File lib/rack/request.rb, line 105 def get_header(name) @env[name] end
Get a request specific value for ‘name`.
Source
# File lib/rack/request.rb, line 100 def has_header?(name) @env.key? name end
Predicate method to test to see if ‘name` has been set as request specific data
Source
# File lib/rack/request.rb, line 149 def initialize_copy(other) @env = other.env.dup end
Source
# File lib/rack/request.rb, line 121 def set_header(name, v) @env[name] = v end
Set
a request specific value for ‘name` to `v`