Sha256: 2c4bda38a187fc5cf43d77e657b50b02a28de76867a8c713e6ecb5ff47e12918

Contents?: true

Size: 583 Bytes

Versions: 8

Compression:

Stored size: 583 Bytes

Contents

# SHA1 checksum generator
bs = ENV['bs'] ? ENV['bs'].to_i : 4096
require 'digest/md5'
use Rack::ContentLength
use Rack::ContentType, "text/plain"
app = lambda do |env|
  return exit!(5) if env["HTTP_X_FAIL"] == "true"
  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, {}, [ body ] ]
end
run app

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
http_spew-0.7.1 test/content-md5.ru
http_spew-0.7.0 test/content-md5.ru
http_spew-0.6.0 test/content-md5.ru
http_spew-0.5.0 test/content-md5.ru
http_spew-0.4.1 test/content-md5.ru
http_spew-0.4.0 test/content-md5.ru
http_spew-0.3.0 test/content-md5.ru
http_spew-0.2.0 test/content-md5.ru