diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-02-26 21:02:57 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-02-26 21:02:57 +0000 |
commit | 012d2fe51afd46fdddbf62f7ebba5102c7f3361a (patch) | |
tree | 985fd39b4d11acfd6c8f6b2cfc3c29e060cefb74 /lib/raindrops/middleware/proxy.rb | |
parent | ac6b83ea1c277cd798e2f627fa5eee605efab4fe (diff) | |
download | raindrops-012d2fe51afd46fdddbf62f7ebba5102c7f3361a.tar.gz |
It's easier to find this way.
Diffstat (limited to 'lib/raindrops/middleware/proxy.rb')
-rw-r--r-- | lib/raindrops/middleware/proxy.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/raindrops/middleware/proxy.rb b/lib/raindrops/middleware/proxy.rb new file mode 100644 index 0000000..8b2c0c8 --- /dev/null +++ b/lib/raindrops/middleware/proxy.rb @@ -0,0 +1,26 @@ +# -*- encoding: binary -*- +class Raindrops::Middleware::Proxy + def initialize(body, stats) + @body, @stats = body, stats + end + + # yield to the Rack server here for writing + def each + @body.each { |x| yield x } + end + + # the Rack server should call this after #each (usually ensure-d) + def close + @stats.decr_writing + @body.close if @body.respond_to?(:close) + end + + def to_path + @body.to_path + end + + def respond_to?(m) + m = m.to_sym + :close == m || @body.respond_to?(m) + end +end |