From 5a077866bc9ae9b0e8d56a0d1ef2c623dcbd9af3 Mon Sep 17 00:00:00 2001 From: Jonathan del Strother Date: Tue, 2 Sep 2008 17:33:52 +0100 Subject: [PATCH] Don't set Content-Length on 304 responses Commit 8aad8c claimed to do this, but it checks for the 304 status too early, before handle_conditional_get! has overridden it. Signed-off-by: Jonathan del Strother --- actionpack/lib/action_controller/response.rb | 2 +- actionpack/test/controller/render_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/actionpack/lib/action_controller/response.rb b/actionpack/lib/action_controller/response.rb index 5dac412..54a9999 100644 --- a/actionpack/lib/action_controller/response.rb +++ b/actionpack/lib/action_controller/response.rb @@ -129,8 +129,8 @@ module ActionController # :nodoc: def prepare! assign_default_content_type_and_charset! - set_content_length! handle_conditional_get! + set_content_length! convert_content_type! end diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index c4a2bf3..af7b5dd 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -1321,6 +1321,12 @@ class EtagRenderTest < Test::Unit::TestCase assert @response.body.empty? end + def test_render_against_etag_request_should_have_no_content_length_when_match + @request.if_none_match = etag_for("hello david") + get :render_hello_world_from_variable + assert !@response.headers.has_key?("Content-Length") + end + def test_render_against_etag_request_should_200_when_no_match @request.if_none_match = etag_for("hello somewhere else") get :render_hello_world_from_variable -- 1.6.0.1.126.ga118