Permalink
Browse files

Merge branch 'master' of github.com:rails/rails

  • Loading branch information...
2 parents 3506cb7 + 15f9562 commit 8763b78f8949f904dd0b53017555451b83f06884 @dhh dhh committed Dec 21, 2009
@@ -5,6 +5,7 @@ class ActionNotFound < StandardError; end
class Base
attr_internal :response_body
attr_internal :action_name
+ attr_internal :formats
class << self
attr_reader :abstract
@@ -16,7 +16,6 @@ module Rendering
include AbstractController::Logger
included do
- attr_internal :formats
extlib_inheritable_accessor :_view_paths
self._view_paths ||= ActionView::PathSet.new
end
@@ -89,7 +89,7 @@ def _normalize_options(action = nil, options = {}, &blk)
end
if options[:status]
- options[:status] = _interpret_status(options[:status])
+ options[:status] = ActionDispatch::StatusCodes[options[:status]]
end
options[:update] = blk if block_given?
@@ -68,6 +68,10 @@ def location=(url)
headers["Location"] = url
end
+ def status=(status)
+ @_status = ActionDispatch::StatusCodes[status]
+ end
+
# :api: private
def dispatch(name, env)
@_env = env
@@ -92,6 +96,7 @@ def self.for(controller, action, stack)
def initialize(controller, action)
@controller, @action = controller, action
+ @_formats = [Mime::HTML]
end
def call(env)
@@ -1,5 +1,7 @@
module ActionController
module Head
+ include UrlFor
+
# Return a response that has no content (merely headers). The options
# argument is interpreted to be a hash of header names and values.
# This allows you to easily return a response that consists only of
@@ -21,7 +23,10 @@ def head(status, options = {})
headers[key.to_s.dasherize.split(/-/).map { |v| v.capitalize }.join("-")] = value.to_s
end
- render :nothing => true, :status => status, :location => location
+ self.status = status
+ self.location = url_for(location) if location
+ self.content_type = Mime[formats.first]
+ self.response_body = " "
end
end
end
@@ -62,9 +62,9 @@ def redirect_to(options = {}, response_status = {}) #:doc:
private
def _extract_redirect_to_status(options, response_status)
status = if options.is_a?(Hash) && options.key?(:status)
- _interpret_status(options.delete(:status))
+ ActionDispatch::StatusCodes[options.delete(:status)]
elsif response_status.key?(:status)
- _interpret_status(response_status[:status])
+ ActionDispatch::StatusCodes[response_status[:status]]
else
302
end
@@ -86,13 +86,5 @@ def _compute_redirect_to_location(options)
url_for(options)
end.gsub(/[\r\n]/, '')
end
-
- def _interpret_status(status)
- if status.is_a?(Symbol)
- (ActionDispatch::StatusCodes::SYMBOL_TO_STATUS_CODE[status] || 500)
- else
- status.to_i
- end
- end
end
end
@@ -38,7 +38,6 @@ module ActionDispatch
autoload :Request
autoload :Response
autoload :StatusCodes
- autoload :Utils
end
deferrable do
@@ -60,7 +60,7 @@ def cache_control
end
def status=(status)
- @status = status.to_i
+ @status = ActionDispatch::StatusCodes[status]
end
# The response code of the request
@@ -14,6 +14,14 @@ module StatusCodes #:nodoc:
510 => "Not Extended"
}).freeze
+ def self.[](status)
+ if status.is_a?(Symbol)
+ SYMBOL_TO_STATUS_CODE[status] || 500
+ else
+ status.to_i
+ end
+ end
+
# Provides a symbol-to-fixnum lookup for converting a symbol (like
# :created or :not_implemented) into its corresponding HTTP status
# code (like 200 or 501).
@@ -1,20 +0,0 @@
-module ActionDispatch
- module Utils
- # TODO: Pull this into rack core
- # http://github.com/halorgium/rack/commit/feaf071c1de743fbd10bc316830180a9af607278
- def parse_config(config)
- if config =~ /\.ru$/
- cfgfile = ::File.read(config)
- if cfgfile[/^#\\(.*)/]
- opts.parse! $1.split(/\s+/)
- end
- inner_app = eval "Rack::Builder.new {( " + cfgfile + "\n )}.to_app",
- nil, config
- else
- require config
- inner_app = Object.const_get(::File.basename(config, '.rb').capitalize)
- end
- end
- module_function :parse_config
- end
-end

0 comments on commit 8763b78

Please sign in to comment.