lib/xray/middleware.rb in xray-rails-0.1.20 vs lib/xray/middleware.rb in xray-rails-0.1.21

- old
+ new

@@ -57,11 +57,11 @@ end # Modifying the original response obj maintains compatibility with other middlewares if ActionDispatch::Response === response response.body = [body] - response.header['Content-Length'] = content_length unless response.try(:committed?) + response.header['Content-Length'] = content_length unless committed?(response) response.to_a else headers['Content-Length'] = content_length [status, headers, [body]] end @@ -70,9 +70,13 @@ end end end private + + def committed?(response) + response.respond_to?(:committed?) && response.committed? + end def inject_xray_bar!(html) html.sub!(/<body[^>]*>/) { "#{$~}\n#{render_xray_bar}" } end