lib/plezi/handlers/controller_magic.rb in plezi-0.12.6 vs lib/plezi/handlers/controller_magic.rb in plezi-0.12.7
- old
+ new
@@ -131,16 +131,16 @@
raise 'Cannot use "send_data" after headers were sent' if response.headers_sent?
if response.body && response.body.any?
Plezi.warn 'existing response body was cleared by `#send_data`!'
response.body.close if response.body.respond_to? :close
end
- response = data
+ response.body = data
# set headers
content_disposition = options[:inline] ? 'inline' : 'attachment'
content_disposition << "; filename=#{::File.basename(options[:filename])}" if options[:filename]
- response['content-type'] = (options[:type] ||= MimeTypeHelper::MIME_DICTIONARY[::File.extname(options[:filename])])
+ response['content-type'] = (options[:type] ||= options[:filename] && MimeTypeHelper::MIME_DICTIONARY[::File.extname(options[:filename])])
response['content-disposition'] = content_disposition
true
end
# Renders a template file (.slim/.erb/.haml) or an html file (.html) to text and attempts to set the response's 'content-type' header (if it's still empty).