aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-12-31 15:08:00 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2012-12-31 15:08:00 -0200
commit348870d5c53c94eb02135c04297c18be60bd3bb0 (patch)
tree59773c8496352442f5ea67b817ab18d38e91fb63
parente48dc194231830f42f179704596b88215f062c23 (diff)
downloadrails-348870d5c53c94eb02135c04297c18be60bd3bb0.tar.gz
rails-348870d5c53c94eb02135c04297c18be60bd3bb0.tar.bz2
rails-348870d5c53c94eb02135c04297c18be60bd3bb0.zip
Revert "Merge pull request #8665 from senny/8661_should_not_append_charset_if_already_present"
This reverts commit e48dc194231830f42f179704596b88215f062c23, reversing changes made to d38c8caa48a732d41c7402a5e71deece4e313559.
-rw-r--r--actionpack/CHANGELOG.md7
-rw-r--r--actionpack/lib/action_controller/metal/head.rb1
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb10
-rw-r--r--actionpack/test/controller/render_test.rb13
4 files changed, 4 insertions, 27 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 2f4e4c3985..a681a2dc79 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,12 +1,5 @@
## Rails 3.2.10 (unreleased) ##
-* Do not append `charset=` parameter when `head` is called with a
- `:content_type` option.
- Fix #8661.
- Backport #8662.
-
- *Yves Senn*
-
* Clear url helper methods when routes are reloaded by removing the methods
explicitly rather than just clearing the module because it didn't work
properly and could be the source of a memory leak.
diff --git a/actionpack/lib/action_controller/metal/head.rb b/actionpack/lib/action_controller/metal/head.rb
index 4c61bbd6dc..671053566d 100644
--- a/actionpack/lib/action_controller/metal/head.rb
+++ b/actionpack/lib/action_controller/metal/head.rb
@@ -29,7 +29,6 @@ module ActionController
self.status = status
self.location = url_for(location) if location
self.content_type = content_type || (Mime[formats.first] if formats)
- self.response.charset = false if self.response
self.response_body = " "
end
end
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index 60d97c5e77..5797c63924 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -56,7 +56,7 @@ module ActionDispatch # :nodoc:
CONTENT_TYPE = "Content-Type".freeze
SET_COOKIE = "Set-Cookie".freeze
LOCATION = "Location".freeze
-
+
cattr_accessor(:default_charset) { "utf-8" }
include Rack::Response::Helpers
@@ -195,16 +195,12 @@ module ActionDispatch # :nodoc:
return if headers[CONTENT_TYPE].present?
@content_type ||= Mime::HTML
- @charset ||= self.class.default_charset if !defined?(@charset) || @charset != false
+ @charset ||= self.class.default_charset
type = @content_type.to_s.dup
- type << "; charset=#{@charset}" if append_charset?
+ type << "; charset=#{@charset}" unless @sending_file
headers[CONTENT_TYPE] = type
end
-
- def append_charset?
- !@sending_file && @charset != false
- end
end
end
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index be5d25a436..8c631e218f 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -503,10 +503,6 @@ class TestController < ActionController::Base
head :created, :content_type => "application/json"
end
- def head_ok_with_image_png_content_type
- head :ok, :content_type => "image/png"
- end
-
def head_with_location_header
head :location => "/foo"
end
@@ -1201,17 +1197,10 @@ class RenderTest < ActionController::TestCase
def test_head_created_with_application_json_content_type
post :head_created_with_application_json_content_type
assert_blank @response.body
- assert_equal "application/json", @response.header["Content-Type"]
+ assert_equal "application/json", @response.content_type
assert_response :created
end
- def test_head_ok_with_image_png_content_type
- post :head_ok_with_image_png_content_type
- assert_blank @response.body
- assert_equal "image/png", @response.header["Content-Type"]
- assert_response :ok
- end
-
def test_head_with_location_header
get :head_with_location_header
assert_blank @response.body