lib/angelo/base.rb in angelo-0.3.1 vs lib/angelo/base.rb in angelo-0.3.2

- old
+ new

@@ -256,11 +256,11 @@ task :handle_event_source do |socket, block| begin block[socket] rescue Reel::SocketError, IOError, SystemCallError => e # probably closed on client - warn e.message if report_errors + warn e.message if report_errors? socket.close unless socket.closed? rescue => e error e.inspect socket.close unless socket.closed? end @@ -269,10 +269,11 @@ def halt status = 400, body = '' throw :halt, HALT_STRUCT.new(status, body) end def send_file local_file, opts = {} - lp = self.class.local_path local_file + lp = local_file[0] == File::SEPARATOR ? local_file : File.expand_path(File.join(self.class.root, local_file)) + halt 404 unless File.exist? lp # Content-Type # headers CONTENT_TYPE_HEADER_KEY => (MIME::Types.type_for(File.extname(lp))[0].content_type rescue HTML_TYPE)