From 103e18c87d50a53cd0a33b4e03f2c8a8eff19ece Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Fri, 31 Jan 2014 15:37:58 -0500 Subject: Introduce `render :body` for render raw content This is an option for sending a raw content back to browser. Note that this rendering option will unset the default content type and does not include "Content-Type" header back in the response. You should only use this option if you are expecting the "Content-Type" header to not be set. More information on "Content-Type" header can be found on RFC 2616, section 7.2.1. Please see #12374 for more detail. --- actionpack/test/dispatch/response_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'actionpack/test/dispatch/response_test.rb') diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index 959a3bc5cd..26b77dfaf7 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -235,6 +235,14 @@ class ResponseTest < ActiveSupport::TestCase assert_equal @response.body, body.each.to_a.join end end + + test "does not add default content-type if Content-Type is none" do + resp = ActionDispatch::Response.new.tap { |response| + response.content_type = 'none' + } + + assert_not resp.headers.has_key?('Content-Type') + end end class ResponseIntegrationTest < ActionDispatch::IntegrationTest -- cgit v1.2.3 From 3047376870d4a7adc7ff15c3cb4852e073c8f1da Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Fri, 14 Feb 2014 15:50:08 -0500 Subject: Add `#no_content_type` attribute to `AD::Response` Setting this attribute to `true` will remove the content type header from the request. This is use in `render :body` feature. --- actionpack/test/dispatch/response_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/dispatch/response_test.rb') diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index 26b77dfaf7..1360ede3f8 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -238,7 +238,7 @@ class ResponseTest < ActiveSupport::TestCase test "does not add default content-type if Content-Type is none" do resp = ActionDispatch::Response.new.tap { |response| - response.content_type = 'none' + response.no_content_type = true } assert_not resp.headers.has_key?('Content-Type') -- cgit v1.2.3