提交 f5383ee3 编写于 作者: J Jeremy Kemper

Merge pull request #16793 from javan/comply_with_rack_content_length_middleware

Add support for Rack::ContentLength middelware
......@@ -380,6 +380,10 @@ def respond_to?(method, include_private = false)
def to_path
@response.stream.to_path
end
def to_ary
nil
end
end
def rack_response(status, header)
......
require 'abstract_unit'
require 'timeout'
require 'rack/content_length'
class ResponseTest < ActiveSupport::TestCase
def setup
......@@ -238,6 +240,18 @@ def test_response_body_encoding
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'])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册