From 82279dee9454f0dd7b327e738402649c2678fe0a Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 5 Mar 2012 14:14:41 -0500 Subject: [PATCH] try another change --- lib/rack/livereload.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/rack/livereload.rb b/lib/rack/livereload.rb index 4323f74..45b5798 100644 --- a/lib/rack/livereload.rb +++ b/lib/rack/livereload.rb @@ -53,15 +53,19 @@ module Rack else status, headers, body = @app.call(env) - new_body = body.dup + new_body = [] + + body.each do |line| + new_body << line + end + + body.close if body.respond_to?(:close) if !ignored?(env['PATH_INFO']) && !bad_browser?(env['HTTP_USER_AGENT']) if headers['Content-Type'] && headers['Content-Type'][%r{text/html}] content_length = 0 - new_body = [] - - body.each do |line| + new_body.each do |line| if !headers['X-Rack-LiveReload'] && line[''] host_to_use = (@options[:host] || env['HTTP_HOST'] || 'localhost').gsub(%r{:.*}, '') @@ -83,17 +87,12 @@ module Rack end content_length += line.bytesize - - new_body << line end headers['Content-Length'] = content_length.to_s end end - body.close if body.respond_to?(:close) - new_body.close if new_body.respond_to?(:close) - [ status, headers, new_body ] end end