From 1468604be898d17c2cf2da519dccd493c58f4282 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 10 Jun 2011 22:08:04 +0000 Subject: ev_core: do not autochunk HTTP/1.0 (and 0.9) responses Do not assume middlewares/applications are stupid and blindly add chunking to responses (we have precedence set by Rack::Chunked). --- t/async-response-no-autochunk.ru | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 't') 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 } -- cgit v1.2.3-24-ge0c7