lib/simple_captcha/middleware.rb in glebtv-simple_captcha-0.6.2 vs lib/simple_captcha/middleware.rb in glebtv-simple_captcha-0.6.3
- old
+ new
@@ -26,13 +26,15 @@
request = Rack::Request.new(env)
code = request.params["code"]
body = []
if !code.blank? && Utils::simple_captcha_value(code)
return send_file(generate_simple_captcha_image(code), :type => 'image/jpeg', :disposition => 'inline', :filename => 'simple_captcha.jpg')
+ else
+ [500, {
+ "Content-Type" => 'text/plain',
+ }, "captcha error"]
end
-
- [status, headers, body]
end
def captcha_path?(request_path)
request_path.include?('/simple_captcha')
end
@@ -46,10 +48,10 @@
options[:filename] ||= File.basename(path) unless options[:url_based_filename]
status = options[:status] || 200
headers = {
"Content-Disposition" => "#{options[:disposition]}; filename='#{options[:filename]}'",
- # "Content-Type" => options[:type],
+ "Content-Type" => options[:type],
'Content-Transfer-Encoding' => 'binary',
'Cache-Control' => 'private'
}
response_body = [File.open(path, "rb").read]
File.delete(path)