ensure you're actually working with real lines, not assuming the return value is an array you can mutate, fixes #6
This commit is contained in:
parent
e223e1ddbf
commit
00a9eb9062
@ -5,10 +5,13 @@ require 'rack/livereload'
|
||||
|
||||
use Rack::Logger
|
||||
use Rack::LiveReload
|
||||
run Rack::Directory.new('.')
|
||||
|
||||
if false
|
||||
|
||||
get '/' do
|
||||
File.read('index.html')
|
||||
end
|
||||
|
||||
run Sinatra::Application
|
||||
|
||||
end
|
||||
|
@ -49,10 +49,14 @@ module Rack
|
||||
else
|
||||
status, headers, body = @app.call(env)
|
||||
|
||||
new_body = body.dup
|
||||
|
||||
if !ignored?(env['PATH_INFO']) && !bad_browser?(env['HTTP_USER_AGENT'])
|
||||
if headers['Content-Type'][%r{text/html}]
|
||||
content_length = 0
|
||||
|
||||
new_body = []
|
||||
|
||||
body.each do |line|
|
||||
if !headers['X-Rack-LiveReload'] && line['</head>']
|
||||
host_to_use = (@options[:host] || env['HTTP_HOST'] || 'localhost').gsub(%r{:.*}, '')
|
||||
@ -75,13 +79,15 @@ module Rack
|
||||
end
|
||||
|
||||
content_length += line.length
|
||||
|
||||
new_body << line
|
||||
end
|
||||
|
||||
headers['Content-Length'] = content_length.to_s
|
||||
end
|
||||
end
|
||||
|
||||
[ status, headers, body ]
|
||||
[ status, headers, new_body ]
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user