1 # SHA1 checksum generator
2 bs = ENV['bs'] ? ENV['bs'].to_i : 4096
4 use Rack::ContentLength
6 /\A100-continue\z/i =~ env['HTTP_EXPECT'] and
8 digest = Digest::MD5.new
9 input = env['rack.input']
10 if buf = input.read(bs)
13 end while input.read(bs, buf)
16 expect = env['HTTP_CONTENT_MD5']
17 readed = [ digest.digest ].pack('m').strip
18 body = "expect=#{expect}\nreaded=#{readed}\n"
19 status = expect == readed ? 200 : 500
21 [ status, {'Content-Type' => 'text/plain'}, [ body ] ]