about summary refs log tree commit homepage
path: root/lib/unicorn/util.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unicorn/util.rb')
-rw-r--r--lib/unicorn/util.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/unicorn/util.rb b/lib/unicorn/util.rb
index 4bbc590..6444699 100644
--- a/lib/unicorn/util.rb
+++ b/lib/unicorn/util.rb
@@ -4,6 +4,16 @@ require 'fcntl'
 require 'tmpdir'
 
 module Unicorn
+
+  class TmpIO < ::File
+
+    # for easier env["rack.input"] compatibility
+    def size
+      # flush if sync
+      stat.size
+    end
+  end
+
   class Util
     class << self
 
@@ -47,8 +57,8 @@ module Unicorn
       # buffering is disabled
       def tmpio
         fp = begin
-          File.open("#{Dir::tmpdir}/#{rand}",
-                    File::RDWR|File::CREAT|File::EXCL, 0600)
+          TmpIO.open("#{Dir::tmpdir}/#{rand}",
+                     File::RDWR|File::CREAT|File::EXCL, 0600)
         rescue Errno::EEXIST
           retry
         end