lib/bulletware.rb in flyerhzm-bullet-1.5.9 vs lib/bulletware.rb in flyerhzm-bullet-1.5.10
- old
+ new
@@ -6,11 +6,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 response.empty?
+ return [status, headers, response] if empty?(response)
if Bullet.notification?
if check_html?(headers, response)
response_body = response.body << Bullet.javascript_notification
headers['Content-Length'] = response_body.length.to_s
@@ -21,9 +21,14 @@
end
response_body ||= response.body
Bullet.end_request
no_browser_cache(headers) if Bullet.disable_browser_cache
[status, headers, response_body]
+ end
+
+ # fix issue if response's body is a Proc
+ def empty?(response)
+ (response.is_a?(Array) && response.empty?) || !response.body.is_a?(String) || response.body.empty?
end
def check_html?(headers, response)
!headers['Content-Type'].nil? and headers['Content-Type'].include? 'text/html' and response.body =~ %r{<html.*</html>}m
end