about summary refs log tree commit homepage
path: root/t/sha1.ru
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-07 01:57:16 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-07 01:57:16 -0800
commit1266417999aeb939d4e2a7d01aa6730f13cae9fa (patch)
tree1ac533a1f48eacaff92ef585cf0205d926094297 /t/sha1.ru
parent60900208616ee5b41716b23215a0fce33bc3eb5a (diff)
downloadrainbows-1266417999aeb939d4e2a7d01aa6730f13cae9fa.tar.gz
env['rack.input']read(length) may return nil zero-sized inputs
Diffstat (limited to 't/sha1.ru')
-rw-r--r--t/sha1.ru9
1 files changed, 5 insertions, 4 deletions
diff --git a/t/sha1.ru b/t/sha1.ru
index ec81fa4..55e91ab 100644
--- a/t/sha1.ru
+++ b/t/sha1.ru
@@ -7,10 +7,11 @@ app = lambda do |env|
     return [ 100, {}, [] ]
   digest = Digest::SHA1.new
   input = env['rack.input']
-  buf = input.read(bs)
-  begin
-    digest.update(buf)
-  end while input.read(bs, buf)
+  if buf = input.read(bs)
+    begin
+      digest.update(buf)
+    end while input.read(bs, buf)
+  end
 
   [ 200, {'Content-Type' => 'text/plain'}, [ digest.hexdigest << "\n" ] ]
 end