about summary refs log tree commit homepage
path: root/examples
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-07-03 22:30:48 -0700
committerEric Wong <normalperson@yhbt.net>2009-07-04 01:13:42 -0700
commitff0fc020fe30798e52d96cc11b445c76d9822422 (patch)
tree986dfb9b874de6801646e86ea4ba7654b61bd59b /examples
parent672befaa67ace119c07ee346124526c1e0c4a1f1 (diff)
downloadunicorn-ff0fc020fe30798e52d96cc11b445c76d9822422.tar.gz
There's a small memory reduction to be had when forking
oodles of processes and the Perl hacker in me still
gets confused into thinking those are arrays...
Diffstat (limited to 'examples')
-rw-r--r--examples/echo.ru11
1 files changed, 3 insertions, 8 deletions
diff --git a/examples/echo.ru b/examples/echo.ru
index 322fe94..c79cb7b 100644
--- a/examples/echo.ru
+++ b/examples/echo.ru
@@ -8,25 +8,20 @@
 #
 # Then type random stuff in your terminal to watch it get echoed back!
 
-class EchoBody
-  def initialize(input)
-    @input = input
-  end
+class EchoBody < Struct.new(:input)
 
   def each(&block)
-    while buf = @input.read(4096)
+    while buf = input.read(4096)
       yield buf
     end
     self
   end
 
-  def close
-    @input = nil
-  end
 end
 
 use Rack::Chunked
 run lambda { |env|
+  /\A100-continue\z/ =~ env['HTTP_EXPECT'] and return [100, {}, []]
   [ 200, { 'Content-Type' => 'application/octet-stream' },
     EchoBody.new(env['rack.input']) ]
 }