diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-11-07 01:57:16 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-11-07 01:57:16 -0800 |
commit | 1266417999aeb939d4e2a7d01aa6730f13cae9fa (patch) | |
tree | 1ac533a1f48eacaff92ef585cf0205d926094297 /t/sha1.ru | |
parent | 60900208616ee5b41716b23215a0fce33bc3eb5a (diff) | |
download | rainbows-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.ru | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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 |