mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
only call self.content_type= when there is a response
Apparently the AbstractController (whatever "abstract" means) is expected to work without a request and response.
This commit is contained in:
parent
2ceb16e539
commit
3b8395a882
3 changed files with 18 additions and 4 deletions
|
@ -24,7 +24,11 @@ module AbstractController
|
||||||
options = _normalize_render(*args, &block)
|
options = _normalize_render(*args, &block)
|
||||||
self.response_body = render_to_body(options)
|
self.response_body = render_to_body(options)
|
||||||
_process_format(rendered_format) if rendered_format
|
_process_format(rendered_format) if rendered_format
|
||||||
self.content_type = Mime::TEXT if options[:plain]
|
if options[:plain]
|
||||||
|
_set_content_type Mime::TEXT.to_s
|
||||||
|
else
|
||||||
|
_set_content_type _get_content_type(rendered_format)
|
||||||
|
end
|
||||||
self.response_body
|
self.response_body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,6 +107,13 @@ module AbstractController
|
||||||
def _process_format(format)
|
def _process_format(format)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def _get_content_type(rendered_format) # :nodoc:
|
||||||
|
rendered_format.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def _set_content_type(type) # :nodoc:
|
||||||
|
end
|
||||||
|
|
||||||
# Normalize args and options.
|
# Normalize args and options.
|
||||||
# :api: private
|
# :api: private
|
||||||
def _normalize_render(*args, &block)
|
def _normalize_render(*args, &block)
|
||||||
|
|
|
@ -191,6 +191,7 @@ module ActionController #:nodoc:
|
||||||
|
|
||||||
if format = collector.negotiate_format(request)
|
if format = collector.negotiate_format(request)
|
||||||
_process_format(format)
|
_process_format(format)
|
||||||
|
_set_content_type _get_content_type format
|
||||||
response = collector.response
|
response = collector.response
|
||||||
response ? response.call : render({})
|
response ? response.call : render({})
|
||||||
else
|
else
|
||||||
|
|
|
@ -56,10 +56,12 @@ module ActionController
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def _process_format(format)
|
def _get_content_type(rendered_format)
|
||||||
super
|
self.content_type || super
|
||||||
|
end
|
||||||
|
|
||||||
self.content_type ||= format.to_s
|
def _set_content_type(format)
|
||||||
|
self.content_type = format
|
||||||
end
|
end
|
||||||
|
|
||||||
# Normalize arguments by catching blocks and setting them on :update.
|
# Normalize arguments by catching blocks and setting them on :update.
|
||||||
|
|
Loading…
Reference in a new issue