test/content-md5.ru in http_spew-0.1.0 vs test/content-md5.ru in http_spew-0.2.0
- old
+ new
@@ -1,10 +1,12 @@
# 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)
@@ -14,8 +16,8 @@
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 ] ]
+ [ status, {}, [ body ] ]
end
run app