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::Logger
|
||||||
use Rack::LiveReload
|
use Rack::LiveReload
|
||||||
|
run Rack::Directory.new('.')
|
||||||
|
|
||||||
|
if false
|
||||||
|
|
||||||
get '/' do
|
get '/' do
|
||||||
File.read('index.html')
|
File.read('index.html')
|
||||||
end
|
end
|
||||||
|
|
||||||
run Sinatra::Application
|
run Sinatra::Application
|
||||||
|
end
|
||||||
|
@ -49,10 +49,14 @@ module Rack
|
|||||||
else
|
else
|
||||||
status, headers, body = @app.call(env)
|
status, headers, body = @app.call(env)
|
||||||
|
|
||||||
|
new_body = body.dup
|
||||||
|
|
||||||
if !ignored?(env['PATH_INFO']) && !bad_browser?(env['HTTP_USER_AGENT'])
|
if !ignored?(env['PATH_INFO']) && !bad_browser?(env['HTTP_USER_AGENT'])
|
||||||
if headers['Content-Type'][%r{text/html}]
|
if headers['Content-Type'][%r{text/html}]
|
||||||
content_length = 0
|
content_length = 0
|
||||||
|
|
||||||
|
new_body = []
|
||||||
|
|
||||||
body.each do |line|
|
body.each do |line|
|
||||||
if !headers['X-Rack-LiveReload'] && line['</head>']
|
if !headers['X-Rack-LiveReload'] && line['</head>']
|
||||||
host_to_use = (@options[:host] || env['HTTP_HOST'] || 'localhost').gsub(%r{:.*}, '')
|
host_to_use = (@options[:host] || env['HTTP_HOST'] || 'localhost').gsub(%r{:.*}, '')
|
||||||
@ -75,13 +79,15 @@ module Rack
|
|||||||
end
|
end
|
||||||
|
|
||||||
content_length += line.length
|
content_length += line.length
|
||||||
|
|
||||||
|
new_body << line
|
||||||
end
|
end
|
||||||
|
|
||||||
headers['Content-Length'] = content_length.to_s
|
headers['Content-Length'] = content_length.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
[ status, headers, body ]
|
[ status, headers, new_body ]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user