mirror of https://github.com/rails/rails
Remove single space response body for head request
- The single space response was added due to a bug in safari incb0f8fda96
and807df4fcf0
. - This was removed from the `render nothing: true` in https://github.com/rails/rails/pull/14883. - Removing it from response of :head also. As :head is more obvious alternative to call `render nothing: true`(http://guides.rubyonrails.org/layouts_and_rendering.html#using-head-to-build-header-only-responses), removing it from head method also. - Closes #18253.
This commit is contained in:
parent
0c070ae568
commit
75757c5c3b
|
@ -1,3 +1,15 @@
|
|||
* Using `head` method returns empty response_body instead
|
||||
of returning a single space " ".
|
||||
|
||||
The old behavior was added as a workaround for a bug in an early
|
||||
version of Safari, where the HTTP headers are not returned correctly
|
||||
if the response body has a 0-length. This is been fixed since and
|
||||
the workaround is no longer necessary.
|
||||
|
||||
Fixes #18253.
|
||||
|
||||
*Prathamesh Sonpatki*
|
||||
|
||||
* Fix how polymorphic routes works with objects that implement `to_model`.
|
||||
|
||||
*Travis Grathwell*
|
||||
|
|
|
@ -29,14 +29,14 @@ module ActionController
|
|||
self.status = status
|
||||
self.location = url_for(location) if location
|
||||
|
||||
self.response_body = ""
|
||||
|
||||
if include_content?(self._status_code)
|
||||
self.content_type = content_type || (Mime[formats.first] if formats)
|
||||
self.response.charset = false if self.response
|
||||
self.response_body = " "
|
||||
else
|
||||
headers.delete('Content-Type')
|
||||
headers.delete('Content-Length')
|
||||
self.response_body = ""
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1003,21 +1003,21 @@ class YieldingAroundFiltersTest < ActionController::TestCase
|
|||
def test_first_action_in_multiple_before_action_chain_halts
|
||||
controller = ::FilterTest::TestMultipleFiltersController.new
|
||||
response = test_process(controller, 'fail_1')
|
||||
assert_equal ' ', response.body
|
||||
assert_equal '', response.body
|
||||
assert_equal 1, controller.instance_variable_get(:@try)
|
||||
end
|
||||
|
||||
def test_second_action_in_multiple_before_action_chain_halts
|
||||
controller = ::FilterTest::TestMultipleFiltersController.new
|
||||
response = test_process(controller, 'fail_2')
|
||||
assert_equal ' ', response.body
|
||||
assert_equal '', response.body
|
||||
assert_equal 2, controller.instance_variable_get(:@try)
|
||||
end
|
||||
|
||||
def test_last_action_in_multiple_before_action_chain_halts
|
||||
controller = ::FilterTest::TestMultipleFiltersController.new
|
||||
response = test_process(controller, 'fail_3')
|
||||
assert_equal ' ', response.body
|
||||
assert_equal '', response.body
|
||||
assert_equal 3, controller.instance_variable_get(:@try)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue