lib/bullet/rack.rb in bullet-4.1.0 vs lib/bullet/rack.rb in bullet-4.1.1

- old
+ new

@@ -7,11 +7,11 @@ def call(env) return @app.call(env) unless Bullet.enable? Bullet.start_request status, headers, response = @app.call(env) - return [status, headers, response] if empty?(response) + return [status, headers, response] if file?(headers) || empty?(response) response_body = nil if Bullet.notification? if status == 200 && !response.body.frozen? && html_request?(headers, response) response_body = response.body << Bullet.gather_inline_notifications @@ -29,14 +29,16 @@ # response may be ["Not Found"], ["Move Permanently"], etc. (response.is_a?(Array) && response.size <= 1) || !response.body.is_a?(String) || response.body.empty? end + # if send file? + def file?(headers) + headers["Content-Transfer-Encoding"] == "binary" + end + def html_request?(headers, response) - headers['Content-Type'] && - headers['Content-Type'].include?('text/html') && - response.body.include?("<html>") && - response.body.include?("</html>") + headers['Content-Type'] && headers['Content-Type'].include?('text/html') && response.body.include?("<html>") end def no_browser_cache(headers) headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate" headers["Pragma"] = "no-cache"