Skip to content
Browse files

fixes issue where causing some rackapps to fail. problem is that not …

…all responses respond to #first.
  • Loading branch information...
1 parent 110a54d commit 4c355a37aeac8bc91f8413ccbcb0e9846d09d16a @aishfenton aishfenton committed Nov 15, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/rack/webconsole/assets.rb
View
11 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 4c355a3

Please sign in to comment.
Something went wrong with that request. Please try again.