diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-12-03 01:12:08 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-12-03 01:12:08 +0000 |
commit | c096e735efea5050b0559748633403f0387ea3b3 (patch) | |
tree | d0dac89e2fd29069da04096bf7f70288c6377eb4 /lib | |
parent | 64889d9136fa5466269232c26a2f235dd763d8f0 (diff) | |
download | rainbows-c096e735efea5050b0559748633403f0387ea3b3.tar.gz |
All synchronous models have this fixed in unicorn 3.0.1, so only Rev and EventMachine-based concurrency models require code changes.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rainbows/ev_core.rb | 16 | ||||
-rw-r--r-- | lib/rainbows/rev/client.rb | 10 |
2 files changed, 20 insertions, 6 deletions
diff --git a/lib/rainbows/ev_core.rb b/lib/rainbows/ev_core.rb index e1f5918..8241584 100644 --- a/lib/rainbows/ev_core.rb +++ b/lib/rainbows/ev_core.rb @@ -26,6 +26,9 @@ module Rainbows::EvCore @state = :close end + def want_more + end + def handle_error(e) msg = Rainbows::Error.response(e) and write(msg) ensure @@ -62,7 +65,7 @@ module Rainbows::EvCore case @state when :headers @buf << data - @hp.parse or return + @hp.parse or return want_more @state = :body if 0 == @hp.content_length @input = NULL_IO @@ -72,8 +75,13 @@ module Rainbows::EvCore end when :body if @hp.body_eof? - @state = :trailers - on_read(data) + if @hp.content_length + @input.rewind + app_call + else + @state = :trailers + on_read(data) + end elsif data.size > 0 @hp.filter_body(@buf2, @buf << data) @input << @buf2 @@ -83,6 +91,8 @@ module Rainbows::EvCore if @hp.trailers(@env, @buf << data) @input.rewind app_call + else + want_more end end rescue => e diff --git a/lib/rainbows/rev/client.rb b/lib/rainbows/rev/client.rb index bc85fbd..296a33d 100644 --- a/lib/rainbows/rev/client.rb +++ b/lib/rainbows/rev/client.rb @@ -16,6 +16,10 @@ module Rainbows @deferred = nil end + def want_more + enable unless enabled? + end + def quit super close if @deferred.nil? && @_write_buffer.empty? @@ -143,13 +147,13 @@ module Rainbows when :close close if @_write_buffer.empty? when :headers - if @hp.parse - app_call - else + if @buf.empty? unless enabled? enable KATO[self] = Time.now end + else + on_read("") end end rescue => e |