summary refs log tree commit homepage
path: root/t/preread_input.ru
diff options
context:
space:
mode:
Diffstat (limited to 't/preread_input.ru')
-rw-r--r--t/preread_input.ru17
1 files changed, 17 insertions, 0 deletions
diff --git a/t/preread_input.ru b/t/preread_input.ru
new file mode 100644
index 0000000..79685c4
--- /dev/null
+++ b/t/preread_input.ru
@@ -0,0 +1,17 @@
+#\-E none
+require 'digest/sha1'
+require 'unicorn/preread_input'
+use Rack::ContentLength
+use Rack::ContentType, "text/plain"
+use Unicorn::PrereadInput
+nr = 0
+run lambda { |env|
+  $stderr.write "app dispatch: #{nr += 1}\n"
+  input = env["rack.input"]
+  dig = Digest::SHA1.new
+  while buf = input.read(16384)
+    dig.update(buf)
+  end
+
+  [ 200, {}, [ "#{dig.hexdigest}\n" ] ]
+}