Sha256: 1df98e05696d8e1eeb9da6675353ff4dc2d83e5f0ec5889b4e4dc9f934286de0

Contents?: true

Size: 602 Bytes

Versions: 52

Compression:

Stored size: 602 Bytes

Contents

# SHA1 checksum generator
bs = ENV['bs'] ? ENV['bs'].to_i : 4096
require 'digest/md5'
use Rack::ContentLength
app = lambda do |env|
  /\A100-continue\z/i =~ env['HTTP_EXPECT'] and
    return [ 100, {}, [] ]
  digest = Digest::MD5.new
  input = env['rack.input']
  if buf = input.read(bs)
    begin
      digest.update(buf)
    end while input.read(bs, buf)
  end

  expect = env['HTTP_CONTENT_MD5']
  readed = [ digest.digest ].pack('m').strip
  body = "expect=#{expect}\nreaded=#{readed}\n"
  status = expect == readed ? 200 : 500

  [ status, {'Content-Type' => 'text/plain'}, [ body ] ]
end
run app

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
rainbows-5.2.1 t/content-md5.ru
rainbows-5.2.0 t/content-md5.ru
rainbows-5.1.1 t/content-md5.ru
rainbows-5.1.0 t/content-md5.ru
rainbows-5.0.0.5.ge717 t/content-md5.ru
rainbows-5.0.0 t/content-md5.ru
rainbows-4.7.0 t/content-md5.ru
rainbows-4.6.2 t/content-md5.ru
rainbows-4.6.1 t/content-md5.ru
rainbows-4.6.0.4.g4108 t/content-md5.ru
rainbows-4.6.0 t/content-md5.ru
rainbows-4.5.0 t/content-md5.ru
rainbows-4.4.3 t/content-md5.ru
rainbows-4.4.2 t/content-md5.ru
rainbows-4.4.1.1.gd5c8c t/content-md5.ru
rainbows-4.4.1 t/content-md5.ru
rainbows-4.4.0 t/content-md5.ru
rainbows-4.3.1 t/content-md5.ru
rainbows-4.3.0 t/content-md5.ru
rainbows-4.2.0 t/content-md5.ru