about summary refs log tree commit homepage
diff options
context:
space:
mode:
-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