diff options
Diffstat (limited to 't')
-rw-r--r-- | t/async-response-no-autochunk.ru | 30 |
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 } |