about summary refs log tree commit homepage
path: root/lib/rainbows/revactor
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-05-03 17:56:00 -0700
committerEric Wong <normalperson@yhbt.net>2010-05-03 17:56:00 -0700
commitde3bcfe3ba9402bd510f7414df1763b6b99dae47 (patch)
tree180526ea73118ed9e3b0cc606684288991875b72 /lib/rainbows/revactor
parent54cae80e543a6f4ca6456fe07b88aba867d215a6 (diff)
downloadrainbows-de3bcfe3ba9402bd510f7414df1763b6b99dae47.tar.gz
WAvoid mucking with Unicorn::TeeInput, since other apps may
depend on that class, so we subclass it as Rainbows::TeeInput
and modify as necessary in worker processes.

For Revactor, remove the special-cased
Rainbows::Revactor::TeeInput class and instead emulate
readpartial for Revactor sockets instead.
Diffstat (limited to 'lib/rainbows/revactor')
-rw-r--r--lib/rainbows/revactor/tee_input.rb52
1 files changed, 0 insertions, 52 deletions
diff --git a/lib/rainbows/revactor/tee_input.rb b/lib/rainbows/revactor/tee_input.rb
deleted file mode 100644
index 99d1f7d..0000000
--- a/lib/rainbows/revactor/tee_input.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- encoding: binary -*-
-require 'rainbows/revactor'
-
-module Rainbows
-  module Revactor
-
-    # acts like tee(1) on an input input to provide a input-like stream
-    # while providing rewindable semantics through a File/StringIO
-    # backing store.  On the first pass, the input is only read on demand
-    # so your Rack application can use input notification (upload progress
-    # and like).  This should fully conform to the Rack::InputWrapper
-    # specification on the public API.  This class is intended to be a
-    # strict interpretation of Rack::InputWrapper functionality and will
-    # not support any deviations from it.
-    class TeeInput < ::Unicorn::TeeInput
-
-    private
-
-      # tees off a +length+ chunk of data from the input into the IO
-      # backing store as well as returning it.  +dst+ must be specified.
-      # returns nil if reading from the input returns nil
-      def tee(length, dst)
-        unless parser.body_eof?
-          if parser.filter_body(dst, buf << socket.read).nil?
-            tmp.write(dst)
-            diff = dst.size - length
-            if diff > 0
-              dst.replace(dst[0,length])
-              tmp.seek(-diff, IO::SEEK_CUR)
-            end
-            return dst
-          end
-        end
-        finalize_input
-        rescue => e
-          client_error(e)
-      end
-
-      def finalize_input
-        while parser.trailers(req, buf).nil?
-          # Don't worry about raising ClientShutdown here on EOFError, tee()
-          # will catch EOFError when app is processing it, otherwise in
-          # initialize we never get any chance to enter the app so the
-          # EOFError will just get trapped by Unicorn and not the Rack app
-          buf << socket.read
-        end
-        self.socket = nil
-      end
-
-    end
-  end
-end