Class: ActionController::CgiRequest
Overview
Constant Summary
collapse
- DEFAULT_SESSION_OPTIONS =
{
:database_manager => CGI::Session::PStore,
:prefix => "ruby_sess.",
:session_path => "/"
}
Instance Attribute Summary collapse
Instance Method Summary
collapse
#delete?, #domain, #formatted_post?, #get?, #head?, #host_with_port, #method, #parameters, #path, #path_parameters, #path_parameters=, #port_string, #post?, #post_format, #protocol, #put?, #raw_post, #relative_url_root, #remote_ip, #request_uri, #server_software, #ssl?, #standard_port, #subdomains, #symbolized_path_parameters, #xml_http_request?, #xml_post?, #yaml_post?
Constructor Details
#initialize(cgi, session_options = {}) ⇒ CgiRequest
Returns a new instance of CgiRequest.
43
44
45
46
47
|
# File 'lib/action_controller/cgi_process.rb', line 43
def initialize(cgi, session_options = {})
@cgi = cgi
@session_options = session_options
super()
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *arguments) ⇒ Object
125
126
127
|
# File 'lib/action_controller/cgi_process.rb', line 125
def method_missing(method_id, *arguments)
@cgi.send(method_id, *arguments) rescue super
end
|
Instance Attribute Details
Returns the value of attribute cgi.
35
36
37
|
# File 'lib/action_controller/cgi_process.rb', line 35
def cgi
@cgi
end
|
#session_options ⇒ Object
Returns the value of attribute session_options.
35
36
37
|
# File 'lib/action_controller/cgi_process.rb', line 35
def session_options
@session_options
end
|
Instance Method Details
77
78
79
|
# File 'lib/action_controller/cgi_process.rb', line 77
def cookies
@cgi.cookies.freeze
end
|
73
74
75
|
# File 'lib/action_controller/cgi_process.rb', line 73
def env
@cgi.send(:env_table)
end
|
81
82
83
|
# File 'lib/action_controller/cgi_process.rb', line 81
def host
env["HTTP_X_FORWARDED_HOST"] || ($1 if env['HTTP_HOST'] && /^(.*):\d+$/ =~ env['HTTP_HOST']) || @cgi.host.to_s.split(":").first || ''
end
|
85
86
87
|
# File 'lib/action_controller/cgi_process.rb', line 85
def port
env["HTTP_X_FORWARDED_HOST"] ? standard_port : (port_from_http_host || super)
end
|
#port_from_http_host ⇒ Object
89
90
91
|
# File 'lib/action_controller/cgi_process.rb', line 89
def port_from_http_host
$1.to_i if env['HTTP_HOST'] && /:(\d+)$/ =~ env['HTTP_HOST']
end
|
#query_parameters ⇒ Object
61
62
63
|
# File 'lib/action_controller/cgi_process.rb', line 61
def query_parameters
(qs = self.query_string).empty? ? {} : CGIMethods.parse_query_parameters(qs)
end
|
#query_string ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/action_controller/cgi_process.rb', line 49
def query_string
if (qs = @cgi.query_string) && !qs.empty?
qs
elsif uri = env['REQUEST_URI']
parts = uri.split('?')
parts.shift
parts.join('?')
else
env['QUERY_STRING'] || ''
end
end
|
#reset_session ⇒ Object
120
121
122
123
|
# File 'lib/action_controller/cgi_process.rb', line 120
def reset_session
@session.delete if CGI::Session === @session
@session = (@session_options == false ? {} : new_session)
end
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/action_controller/cgi_process.rb', line 93
def session
return @session unless @session.nil?
begin
@session = (@session_options == false ? {} : CGI::Session.new(@cgi, session_options_with_string_keys))
@session["__valid_session"]
return @session
rescue ArgumentError => e
if e.message =~ %r{undefined class/module (\w+)}
begin
Module.const_missing($1)
rescue LoadError, NameError => e
raise(
ActionController::SessionRestoreError,
"Session contained objects where the class definition wasn't available. " +
"Remember to require classes for all objects kept in the session. " +
"(Original exception: #{e.message} [#{e.class}])"
)
end
retry
else
raise
end
end
end
|