1 # SHA1 checksum generator
3 use Rack::ContentLength
6 /\A100-continue\z/i =~ env['HTTP_EXPECT'] and
8 digest = Digest::SHA1.new
9 input = env['rack.input']
10 input.size if env["PATH_INFO"] == "/size_first"
11 input.rewind if env["PATH_INFO"] == "/rewind_first"
12 if buf = input.read(rand(cap))
14 raise "#{buf.size} > #{cap}" if buf.size > cap
16 end while input.read(rand(cap), buf)
19 [ 200, {'Content-Type' => 'text/plain'}, [ digest.hexdigest << "\n" ] ]