Class: ActionController::AbstractResponse
- Defined in:
- lib/action_controller/response.rb
Overview
:nodoc:
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_HEADERS =
{ "Cache-Control" => "no-cache" }
Instance Attribute Summary collapse
-
#assigns ⇒ Object
Returns the value of attribute assigns.
-
#body ⇒ Object
Returns the value of attribute body.
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#redirected_to ⇒ Object
Returns the value of attribute redirected_to.
-
#redirected_to_method_params ⇒ Object
Returns the value of attribute redirected_to_method_params.
-
#request ⇒ Object
Returns the value of attribute request.
-
#session ⇒ Object
Returns the value of attribute session.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
- #charset ⇒ Object
- #charset=(encoding) ⇒ Object
- #content_type ⇒ Object
- #content_type=(mime_type) ⇒ Object
-
#initialize ⇒ AbstractResponse
constructor
A new instance of AbstractResponse.
- #prepare! ⇒ Object
- #redirect(to_url, response_status) ⇒ Object
Constructor Details
#initialize ⇒ AbstractResponse
Returns a new instance of AbstractResponse.
9 10 11 |
# File 'lib/action_controller/response.rb', line 9 def initialize @body, @headers, @session, @assigns = "", DEFAULT_HEADERS.merge("cookie" => []), [], [] end |
Instance Attribute Details
#assigns ⇒ Object
Returns the value of attribute assigns.
7 8 9 |
# File 'lib/action_controller/response.rb', line 7 def assigns @assigns end |
#body ⇒ Object
Returns the value of attribute body.
7 8 9 |
# File 'lib/action_controller/response.rb', line 7 def body @body end |
#cookies ⇒ Object
Returns the value of attribute cookies.
7 8 9 |
# File 'lib/action_controller/response.rb', line 7 def @cookies end |
#headers ⇒ Object
Returns the value of attribute headers.
7 8 9 |
# File 'lib/action_controller/response.rb', line 7 def headers @headers end |
#layout ⇒ Object
Returns the value of attribute layout.
7 8 9 |
# File 'lib/action_controller/response.rb', line 7 def layout @layout end |
#redirected_to ⇒ Object
Returns the value of attribute redirected_to.
7 8 9 |
# File 'lib/action_controller/response.rb', line 7 def redirected_to @redirected_to end |
#redirected_to_method_params ⇒ Object
Returns the value of attribute redirected_to_method_params.
7 8 9 |
# File 'lib/action_controller/response.rb', line 7 def redirected_to_method_params @redirected_to_method_params end |
#request ⇒ Object
Returns the value of attribute request.
6 7 8 |
# File 'lib/action_controller/response.rb', line 6 def request @request end |
#session ⇒ Object
Returns the value of attribute session.
7 8 9 |
# File 'lib/action_controller/response.rb', line 7 def session @session end |
#template ⇒ Object
Returns the value of attribute template.
7 8 9 |
# File 'lib/action_controller/response.rb', line 7 def template @template end |
Instance Method Details
#charset ⇒ Object
26 27 28 29 |
# File 'lib/action_controller/response.rb', line 26 def charset charset = String(headers["Content-Type"] || headers["type"]).split(";")[1] charset.blank? ? nil : charset.strip.split("=")[1] end |
#charset=(encoding) ⇒ Object
22 23 24 |
# File 'lib/action_controller/response.rb', line 22 def charset=(encoding) self.headers["Content-Type"] = "#{content_type || Mime::HTML}; charset=#{encoding}" end |
#content_type ⇒ Object
17 18 19 20 |
# File 'lib/action_controller/response.rb', line 17 def content_type content_type = String(headers["Content-Type"] || headers["type"]).split(";")[0] content_type.blank? ? nil : content_type end |
#content_type=(mime_type) ⇒ Object
13 14 15 |
# File 'lib/action_controller/response.rb', line 13 def content_type=(mime_type) self.headers["Content-Type"] = charset ? "#{mime_type}; charset=#{charset}" : mime_type end |
#prepare! ⇒ Object
38 39 40 41 42 |
# File 'lib/action_controller/response.rb', line 38 def prepare! handle_conditional_get! convert_content_type! set_content_length! end |
#redirect(to_url, response_status) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/action_controller/response.rb', line 31 def redirect(to_url, response_status) self.headers["Status"] = response_status self.headers["Location"] = to_url self.body = "<html><body>You are being <a href=\"#{to_url}\">redirected</a>.</body></html>" end |