Permalink
Browse files

Do not stream on HTTP/1.0.

  • Loading branch information...
josevalim committed Apr 19, 2011
1 parent b398520 commit 069e9b004f91c4ace1373ab5203bb00ab41bd1f9
@@ -38,9 +38,13 @@ def _normalize_options(options) #: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
@@ -83,6 +83,14 @@ class StreamingTest < Rack::TestCase
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"]

0 comments on commit 069e9b0

Please sign in to comment.