about summary refs log tree commit homepage
path: root/lib/rainbows/coolio/response_pipe.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows/coolio/response_pipe.rb')
-rw-r--r--lib/rainbows/coolio/response_pipe.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/rainbows/coolio/response_pipe.rb b/lib/rainbows/coolio/response_pipe.rb
new file mode 100644
index 0000000..42483c2
--- /dev/null
+++ b/lib/rainbows/coolio/response_pipe.rb
@@ -0,0 +1,20 @@
+# -*- encoding: binary -*-
+# :enddoc:
+#
+# this is class is specific to Coolio for writing large static files
+# or proxying IO-derived objects
+class Rainbows::Coolio::ResponsePipe < Coolio::IO
+  def initialize(io, client, body)
+    super(io)
+    @client, @body = client, body
+  end
+
+  def on_read(data)
+    @client.write(data)
+  end
+
+  def on_close
+    @body.respond_to?(:close) and @body.close
+    @client.next!
+  end
+end