aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-09-24 10:27:21 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-09-24 13:54:42 -0700
commita2448e74b9de544dd8b3fef7f0da0a91140af492 (patch)
treed0fa197f595bca4f402c523e31025fc9b7586118 /actionpack
parentbd6bea0f1937010b346574ea342cf27593a2415b (diff)
downloadrails-a2448e74b9de544dd8b3fef7f0da0a91140af492.tar.gz
rails-a2448e74b9de544dd8b3fef7f0da0a91140af492.tar.bz2
rails-a2448e74b9de544dd8b3fef7f0da0a91140af492.zip
mutate headers before committing the response
We should not mutate headers after the response has been committed.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb10
1 files changed, 8 insertions, 2 deletions
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)]