Skip to content

Commit

Permalink
Don't set Content-Length on 304 responses
Browse files Browse the repository at this point in the history
Commit 8aad8c claimed to do this, but it checks for the 304 status too early, before handle_conditional_get! has overridden it.

[#958 state:resolved]

Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
Jonathan del Strother authored and jeremy committed Sep 2, 2008
1 parent 6f932b4 commit 6cfb700
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/response.rb
Expand Up @@ -129,8 +129,8 @@ def assign_default_content_type_and_charset!

def prepare!
assign_default_content_type_and_charset!
set_content_length!
handle_conditional_get!
set_content_length!
convert_content_type!
end

Expand Down
6 changes: 6 additions & 0 deletions actionpack/test/controller/render_test.rb
Expand Up @@ -1321,6 +1321,12 @@ def test_render_against_etag_request_should_304_when_match
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
Expand Down

0 comments on commit 6cfb700

Please sign in to comment.