about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-06-10 22:08:04 +0000
committerEric Wong <normalperson@yhbt.net>2011-06-10 22:09:18 +0000
commit1468604be898d17c2cf2da519dccd493c58f4282 (patch)
treeca754932852f0e8f1ccdf3ac64f491d6c81d5fa2 /t
parent1aa7eb6608d04a21d1143e7ac09e5219a1208123 (diff)
downloadrainbows-1468604be898d17c2cf2da519dccd493c58f4282.tar.gz
Do not assume middlewares/applications are stupid and blindly
add chunking to responses (we have precedence set by
Rack::Chunked).
Diffstat (limited to 't')
-rw-r--r--t/async-response-no-autochunk.ru30
1 files changed, 20 insertions, 10 deletions
diff --git a/t/async-response-no-autochunk.ru b/t/async-response-no-autochunk.ru
index 1eda553..9fbe77f 100644
--- a/t/async-response-no-autochunk.ru
+++ b/t/async-response-no-autochunk.ru
@@ -1,6 +1,6 @@
 use Rack::Chunked
 use Rainbows::DevFdResponse
-script = <<-EOF
+script_chunked = <<-EOF
 for i in 0 1 2 3 4 5 6 7 8 9
 do
         printf '1\r\n%s\r\n' $i
@@ -9,15 +9,25 @@ done
 printf '0\r\n\r\n'
 EOF
 
+script_identity = <<-EOF
+for i in 0 1 2 3 4 5 6 7 8 9
+do
+        printf $i
+        sleep 1
+done
+EOF
+
 run lambda { |env|
   env['rainbows.autochunk'] = false
-  io = IO.popen(script, 'rb')
-  [
-    200,
-    {
-      'Content-Type' => 'text/plain',
-      'Transfer-Encoding' => 'chunked',
-    },
-    io
-  ].freeze
+  headers = { 'Content-Type' => 'text/plain' }
+
+  script = case env["HTTP_VERSION"]
+  when nil, "HTTP/1.0"
+    script_identity
+  else
+    headers['Transfer-Encoding'] = 'chunked'
+    script_chunked
+  end
+
+  [ 200, headers, IO.popen(script, 'rb') ].freeze
 }