diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-05 03:40:46 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-05 03:40:46 -0700 |
commit | e35b3f8a9d64f1a0012d450fd68b301a7a869006 (patch) | |
tree | 058757c9108391fb618ad1399d9fbdae0448ca33 /t/sha1.ru | |
parent | 0be3542b4e16972e0ec5ff354625f45ea8241883 (diff) | |
download | rainbows-e35b3f8a9d64f1a0012d450fd68b301a7a869006.tar.gz |
We'll be able to use the SHA1 test in other places, too.
Diffstat (limited to 't/sha1.ru')
-rw-r--r-- | t/sha1.ru | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/t/sha1.ru b/t/sha1.ru new file mode 100644 index 0000000..ec81fa4 --- /dev/null +++ b/t/sha1.ru @@ -0,0 +1,17 @@ +# SHA1 checksum generator +bs = ENV['bs'] ? ENV['bs'].to_i : 4096 +require 'digest/sha1' +use Rack::ContentLength +app = lambda do |env| + /\A100-continue\z/i =~ env['HTTP_EXPECT'] and + return [ 100, {}, [] ] + digest = Digest::SHA1.new + input = env['rack.input'] + buf = input.read(bs) + begin + digest.update(buf) + end while input.read(bs, buf) + + [ 200, {'Content-Type' => 'text/plain'}, [ digest.hexdigest << "\n" ] ] +end +run app |