diff options
author | José Valim <jose.valim@gmail.com> | 2011-04-19 15:04:28 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-04-19 15:04:28 +0200 |
commit | 069e9b004f91c4ace1373ab5203bb00ab41bd1f9 (patch) | |
tree | ee757c414241223251b10a86f4163f1ee4ccc45e | |
parent | b398520c1406824efd12df6bb57996aa9781f876 (diff) | |
download | rails-069e9b004f91c4ace1373ab5203bb00ab41bd1f9.tar.gz rails-069e9b004f91c4ace1373ab5203bb00ab41bd1f9.tar.bz2 rails-069e9b004f91c4ace1373ab5203bb00ab41bd1f9.zip |
Do not stream on HTTP/1.0.
-rw-r--r-- | actionpack/lib/action_controller/metal/streaming.rb | 10 | ||||
-rw-r--r-- | actionpack/test/controller/new_base/render_streaming_test.rb | 8 |
2 files changed, 15 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/metal/streaming.rb b/actionpack/lib/action_controller/metal/streaming.rb index adb3e94134..b9bd49f670 100644 --- a/actionpack/lib/action_controller/metal/streaming.rb +++ b/actionpack/lib/action_controller/metal/streaming.rb @@ -38,9 +38,13 @@ module ActionController #:nodoc: def _process_options(options) #:nodoc: super if options[:stream] - headers["Cache-Control"] ||= "no-cache" - headers["Transfer-Encoding"] = "chunked" - headers.delete("Content-Length") + if env["HTTP_VERSION"] == "HTTP/1.0" + options.delete(:stream) + else + headers["Cache-Control"] ||= "no-cache" + headers["Transfer-Encoding"] = "chunked" + headers.delete("Content-Length") + end end end diff --git a/actionpack/test/controller/new_base/render_streaming_test.rb b/actionpack/test/controller/new_base/render_streaming_test.rb index b8df5ec4e8..fed8d40b47 100644 --- a/actionpack/test/controller/new_base/render_streaming_test.rb +++ b/actionpack/test/controller/new_base/render_streaming_test.rb @@ -83,6 +83,14 @@ module RenderStreaming assert_streaming! end + test "do not stream on HTTP/1.0" do + get "/render_streaming/basic/hello_world", nil, "HTTP_VERSION" => "HTTP/1.0" + assert_body "Hello world, I'm here!" + assert_status 200 + assert_equal "22", headers["Content-Length"] + assert_equal nil, headers["Transfer-Encoding"] + end + def assert_streaming!(cache="no-cache") assert_status 200 assert_equal nil, headers["Content-Length"] |