diff options
author | Jeremy Kemper <jeremykemper@gmail.com> | 2014-09-06 17:11:18 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremykemper@gmail.com> | 2014-09-06 17:11:18 -0700 |
commit | f5383ee3566dbddc0e2faa20f9774c2858b35109 (patch) | |
tree | 65bb417dbf08394ba5735667de77875f08299e1e /actionpack | |
parent | da2f61947db287b5ba0343905da9316eecfd43f3 (diff) | |
parent | 66f8997671c41278a4045ca6c3e3a19c8175a7ed (diff) | |
download | rails-f5383ee3566dbddc0e2faa20f9774c2858b35109.tar.gz rails-f5383ee3566dbddc0e2faa20f9774c2858b35109.tar.bz2 rails-f5383ee3566dbddc0e2faa20f9774c2858b35109.zip |
Merge pull request #16793 from javan/comply_with_rack_content_length_middleware
Add support for Rack::ContentLength middelware
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 4 | ||||
-rw-r--r-- | actionpack/test/dispatch/response_test.rb | 14 |
2 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index a58e904c11..c5e18048da 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -380,6 +380,10 @@ module ActionDispatch # :nodoc: def to_path @response.stream.to_path end + + def to_ary + nil + end end def rack_response(status, header) diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index af188191e3..48342e252a 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -1,4 +1,6 @@ require 'abstract_unit' +require 'timeout' +require 'rack/content_length' class ResponseTest < ActiveSupport::TestCase def setup @@ -238,6 +240,18 @@ class ResponseTest < ActiveSupport::TestCase end end + test "compatibility with Rack::ContentLength" do + @response.body = 'Hello' + app = lambda { |env| @response.to_a } + env = Rack::MockRequest.env_for("/") + + status, headers, body = app.call(env) + assert_nil headers['Content-Length'] + + status, headers, body = Rack::ContentLength.new(app).call(env) + assert_equal '5', headers['Content-Length'] + end + test "implicit destructuring and Array conversion is deprecated" do response = ActionDispatch::Response.new(404, { 'Content-Type' => 'text/plain' }, ['Not Found']) |