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']
12 warn "GETS_READ_MIX #{env['HTTP_TRANSFER_ENCODING'].inspect}"
14 warn "input.rbuf: #{input.instance_variable_get(:@rbuf).inspect}"
17 warn "buf.size : #{buf.size}"
18 end while input.read(rand(cap), buf)
21 input.each { |buf| digest.update(buf) }
23 if buf = input.read(rand(cap))
25 raise "#{buf.size} > #{cap}" if buf.size > cap
27 end while input.read(rand(cap), buf)
31 [ 200, {'Content-Type' => 'text/plain'}, [ digest.hexdigest << "\n" ] ]