about summary refs log tree commit homepage
path: root/lib/rainbows/rack_input.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows/rack_input.rb')
-rw-r--r--lib/rainbows/rack_input.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/rainbows/rack_input.rb b/lib/rainbows/rack_input.rb
new file mode 100644
index 0000000..df51ac1
--- /dev/null
+++ b/lib/rainbows/rack_input.rb
@@ -0,0 +1,17 @@
+# -*- encoding: binary -*-
+# :enddoc:
+# only used by synchronous interfaces
+module Rainbows::RackInput
+  NULL_IO = Unicorn::HttpRequest::NULL_IO
+  RACK_INPUT = Unicorn::HttpRequest::RACK_INPUT
+  CLIENT_IO = Rainbows::Const::CLIENT_IO
+
+  def self.setup
+    const_set(:IC, Unicorn::HttpRequest.input_class)
+  end
+
+  def set_input(env, hp, client)
+    env[RACK_INPUT] = 0 == hp.content_length ? NULL_IO : IC.new(client, hp)
+    env[CLIENT_IO] = client
+  end
+end