diff options
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 |