Skip to content
This repository
Browse code

Do not stream on HTTP/1.0.

  • Loading branch information...
commit 069e9b004f91c4ace1373ab5203bb00ab41bd1f9 1 parent b398520
José Valim authored April 19, 2011
10  actionpack/lib/action_controller/metal/streaming.rb
@@ -38,9 +38,13 @@ def _normalize_options(options) #:nodoc:
38 38
     def _process_options(options) #:nodoc:
39 39
       super
40 40
       if options[:stream]
41  
-        headers["Cache-Control"] ||= "no-cache"
42  
-        headers["Transfer-Encoding"] = "chunked"
43  
-        headers.delete("Content-Length")
  41
+        if env["HTTP_VERSION"] == "HTTP/1.0"
  42
+          options.delete(:stream)
  43
+        else
  44
+          headers["Cache-Control"] ||= "no-cache"
  45
+          headers["Transfer-Encoding"] = "chunked"
  46
+          headers.delete("Content-Length")
  47
+        end
44 48
       end
45 49
     end
46 50
 
8  actionpack/test/controller/new_base/render_streaming_test.rb
@@ -83,6 +83,14 @@ class StreamingTest < Rack::TestCase
83 83
       assert_streaming!
84 84
     end
85 85
 
  86
+    test "do not stream on HTTP/1.0" do
  87
+      get "/render_streaming/basic/hello_world", nil, "HTTP_VERSION" => "HTTP/1.0"
  88
+      assert_body "Hello world, I'm here!"
  89
+      assert_status 200
  90
+      assert_equal "22", headers["Content-Length"]
  91
+      assert_equal nil, headers["Transfer-Encoding"]
  92
+    end
  93
+
86 94
     def assert_streaming!(cache="no-cache")
87 95
       assert_status 200
88 96
       assert_equal nil, headers["Content-Length"]

0 notes on commit 069e9b0

Please sign in to comment.
Something went wrong with that request. Please try again.