about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-10-28 08:20:37 +0000
committerEric Wong <normalperson@yhbt.net>2010-10-28 08:20:37 +0000
commitf84f138233be0607b0151a5a28c3f9190ba336a2 (patch)
tree793b361a7b3d1b1a1f64fa28b26be9accf727dcd
parentc4579db76b9ed5b0286fad852e798e8a890f093c (diff)
downloadrainbows-f84f138233be0607b0151a5a28c3f9190ba336a2.tar.gz
These allow for small reductions in the amount of variables
we have to manage, more changes coming with later Unicorns.
-rw-r--r--lib/rainbows/ev_core.rb7
-rw-r--r--lib/rainbows/event_machine.rb1
-rw-r--r--lib/rainbows/rev/client.rb3
-rw-r--r--lib/rainbows/rev/thread.rb1
4 files changed, 5 insertions, 7 deletions
diff --git a/lib/rainbows/ev_core.rb b/lib/rainbows/ev_core.rb
index 200bf79..3865d79 100644
--- a/lib/rainbows/ev_core.rb
+++ b/lib/rainbows/ev_core.rb
@@ -14,10 +14,10 @@ module Rainbows::EvCore
   ASYNC_CLOSE = "async.close".freeze
 
   def post_init
-    @env = {}
     @hp = HttpParser.new
+    @env = @hp.env
+    @buf = @hp.buf
     @state = :headers # [ :body [ :trailers ] ] :app_call :close
-    @buf = ""
   end
 
   # graceful exit, like SIGQUIT
@@ -47,7 +47,8 @@ module Rainbows::EvCore
   def on_read(data)
     case @state
     when :headers
-      @hp.headers(@env, @buf << data) or return
+      @buf << data
+      @hp.parse or return
       @state = :body
       len = @hp.content_length
       if len == 0
diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb
index 2f363a1..a33fcf7 100644
--- a/lib/rainbows/event_machine.rb
+++ b/lib/rainbows/event_machine.rb
@@ -94,7 +94,6 @@ module Rainbows::EventMachine
       alive = @hp.keepalive? && G.alive && G.kato > 0
       em_write_response(response, alive)
       if alive
-        @env.clear
         @hp.reset
         @state = :headers
         if @buf.empty?
diff --git a/lib/rainbows/rev/client.rb b/lib/rainbows/rev/client.rb
index 20adbc1..e450d09 100644
--- a/lib/rainbows/rev/client.rb
+++ b/lib/rainbows/rev/client.rb
@@ -109,7 +109,6 @@ module Rainbows
 
         rev_write_response(response, alive = @hp.keepalive? && G.alive)
         return quit unless alive && :close != @state
-        @env.clear
         @hp.reset
         @state = :headers
         disable if enabled?
@@ -131,7 +130,7 @@ module Rainbows
         when :close
           close if @_write_buffer.empty?
         when :headers
-          if @hp.headers(@env, @buf)
+          if @hp.parse
             app_call
           else
             unless enabled?
diff --git a/lib/rainbows/rev/thread.rb b/lib/rainbows/rev/thread.rb
index 7b7d455..2356ae2 100644
--- a/lib/rainbows/rev/thread.rb
+++ b/lib/rainbows/rev/thread.rb
@@ -24,7 +24,6 @@ module Rainbows
         rev_write_response(response, alive)
         return quit unless alive && :close != @state
 
-        @env.clear
         @hp.reset
         @state = :headers
       end