about summary refs log tree commit homepage
path: root/lib/rainbows/coolio/response_chunk_pipe.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows/coolio/response_chunk_pipe.rb')
-rw-r--r--lib/rainbows/coolio/response_chunk_pipe.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/rainbows/coolio/response_chunk_pipe.rb b/lib/rainbows/coolio/response_chunk_pipe.rb
new file mode 100644
index 0000000..5e456e9
--- /dev/null
+++ b/lib/rainbows/coolio/response_chunk_pipe.rb
@@ -0,0 +1,16 @@
+# -*- encoding: binary -*-
+# :enddoc:
+#
+# this is class is specific to Coolio for proxying IO-derived objects
+class Rainbows::Coolio::ResponseChunkPipe < Rainbows::Coolio::ResponsePipe
+  def on_read(data)
+    @client.write("#{data.size.to_s(16)}\r\n")
+    @client.write(data)
+    @client.write("\r\n")
+  end
+
+  def on_close
+    @client.write("0\r\n\r\n")
+    super
+  end
+end