Class: Rack::Request

Inherits:
Object
  • Object
show all
Includes:
Env, Helpers
Defined in:
lib/rack/request.rb

Overview

Rack::Request provides a convenient interface to a Rack environment. It is stateless, the environment env passed to the constructor will be directly modified.

req = Rack::Request.new(env)
req.post?
req.params["data"]

Defined Under Namespace

Modules: Env, Helpers

Constant Summary collapse

ALLOWED_SCHEMES =
%w(https http).freeze
SCHEME_WHITELIST =
ALLOWED_SCHEMES

Constants included from Helpers

Helpers::DEFAULT_PORTS, Helpers::FORM_DATA_MEDIA_TYPES, Helpers::HTTP_X_FORWARDED_FOR, Helpers::HTTP_X_FORWARDED_HOST, Helpers::HTTP_X_FORWARDED_PORT, Helpers::HTTP_X_FORWARDED_PROTO, Helpers::HTTP_X_FORWARDED_SCHEME, Helpers::HTTP_X_FORWARDED_SSL, Helpers::PARSEABLE_DATA_MEDIA_TYPES

Class Attribute Summary collapse

Attributes included from Env

#env

Instance Method Summary collapse

Methods included from Helpers

#GET, #POST, #[], #[]=, #accept_encoding, #accept_language, #authority, #base_url, #body, #content_charset, #content_length, #content_type, #cookies, #delete?, #form_data?, #forwarded_authority, #forwarded_for, #forwarded_port, #fullpath, #get?, #head?, #host, #host_authority, #host_with_port, #hostname, #ip, #link?, #logger, #media_type, #media_type_params, #multithread?, #options?, #parseable_data?, #patch?, #path, #path_info, #path_info=, #port, #post?, #put?, #query_string, #referer, #request_method, #scheme, #script_name, #script_name=, #server_authority, #server_name, #server_port, #session, #session_options, #ssl?, #trace?, #trusted_proxy?, #unlink?, #url, #user_agent, #values_at, #xhr?

Methods included from Env

#add_header, #delete_header, #each_header, #fetch_header, #get_header, #has_header?, #initialize_copy, #set_header

Constructor Details

#initialize(env) ⇒ Request

Returns a new instance of Request.



26
27
28
29
# File 'lib/rack/request.rb', line 26

def initialize(env)
  @params = nil
  super(env)
end

Class Attribute Details

.ip_filterObject

Returns the value of attribute ip_filter.



16
17
18
# File 'lib/rack/request.rb', line 16

def ip_filter
  @ip_filter
end

Instance Method Details

#delete_param(k) ⇒ Object



40
41
42
43
44
# File 'lib/rack/request.rb', line 40

def delete_param(k)
  v = super
  @params = nil
  v
end

#paramsObject



31
32
33
# File 'lib/rack/request.rb', line 31

def params
  @params ||= super
end

#update_param(k, v) ⇒ Object



35
36
37
38
# File 'lib/rack/request.rb', line 35

def update_param(k, v)
  super
  @params = nil
end