From a2448e74b9de544dd8b3fef7f0da0a91140af492 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 24 Sep 2015 10:27:21 -0700 Subject: mutate headers before committing the response We should not mutate headers after the response has been committed. --- actionpack/lib/action_dispatch/http/response.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index cbeea9e267..de3ca7d095 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -348,6 +348,7 @@ module ActionDispatch # :nodoc: return if committed? assign_default_content_type_and_charset! handle_conditional_get! + handle_no_content! end def before_sending @@ -405,10 +406,15 @@ module ActionDispatch # :nodoc: end end + def handle_no_content! + if NO_CONTENT_CODES.include?(@status) + @header.delete CONTENT_TYPE + @header.delete 'Content-Length' + end + end + def rack_response(status, header) if NO_CONTENT_CODES.include?(status) - header.delete CONTENT_TYPE - header.delete 'Content-Length' [status, header, []] else [status, header, RackBody.new(self)] -- cgit v1.2.3