diff --git a/lib/camping/reloader.rb b/lib/camping/reloader.rb index ac3a97d..3eeeda0 100644 --- a/lib/camping/reloader.rb +++ b/lib/camping/reloader.rb @@ -93,8 +93,9 @@ def load_apps old_apps = @apps.dup @apps = new_apps.inject({}) do |hash, app| key = app.name.to_sym - hash[key] = old_apps[key] || App.new(self) + hash[key] = (old = old_apps[key]) || App.new(self) hash[key].app = app + app.create if app.respond_to?(:create) && !old hash end self diff --git a/lib/camping/server.rb b/lib/camping/server.rb index 75e4afb..0a8200f 100644 --- a/lib/camping/server.rb +++ b/lib/camping/server.rb @@ -88,6 +88,7 @@ def app end Rack::URLMap.new(hash) end + rapp = Rack::ContentLength.new(rapp) rapp = Rack::Lint.new(rapp) rapp = XSendfile.new(rapp) rapp = Rack::ShowExceptions.new(rapp) @@ -108,8 +109,8 @@ def start handler, conf = case @conf.server when "console" puts "** Starting console" - this = self - eval("self", TOPLEVEL_BINDING).meta_def(:reload!) { this.reload!; nil } + reload! + this = self; eval("self", TOPLEVEL_BINDING).meta_def(:reload!) { this.reload!; nil } ARGV.clear IRB.start exit @@ -145,10 +146,11 @@ def initialize(app) def call(env) status, headers, body = @app.call(env) - headers = Utils::HeaderHash.new(headers) - if path = HEADERS.detect { |header| headers.include?(header) } + headers = Rack::Utils::HeaderHash.new(headers) + if header = HEADERS.detect { |header| headers.include?(header) } + path = headers[header] body = File.read(path) - headers['Content-Length'] = body.length + headers['Content-Length'] = body.length.to_s end [status, headers, body] end