Permalink
Browse files

Merge pull request #2 from aishfenton/master

Fixes issue causing errors on some response objects, such as Rack::File
  • Loading branch information...
2 parents 110a54d + 4c355a3 commit b5159eb9070e5b2a16d80c90bb6c370685d15b2d @mrbrdo committed Nov 16, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/rack/webconsole/assets.rb
@@ -24,6 +24,8 @@ def initialize(app)
# @param [Hash] env a Rack request environment.
def call(env)
status, headers, response = @app.call(env)
+ response.extend(ResponseMethods)
+
return [status, headers, response] unless check_html?(headers, response) && status == 200
if response.respond_to?(:body)
@@ -69,5 +71,14 @@ def check_html?(headers, response)
body =~ %r{<html.*</html>}m
end
end
+
+ module ResponseMethods
+ def first
+ obj = nil
+ self.each { |e| obj = e; break }
+ obj
+ end
+ end
+
end
end

0 comments on commit b5159eb

Please sign in to comment.