lib/slinky/server.rb in slinky-0.4.0 vs lib/slinky/server.rb in slinky-0.4.1

- old
+ new

@@ -32,11 +32,10 @@ # Serves a file from the file system def self.serve_file resp, path if File.exists?(path) && !File.directory?(path) size = File.size(path) _, _, extension = path.match(EXTENSION_REGEX).to_a - resp.content_type MIME::Types.type_for(path).first # File reading code from rack/file.rb File.open path do |file| resp.content = "" while size > 0 part = file.read([8192, size].min) @@ -48,11 +47,11 @@ else not_found resp end end - # Returns the proper responce for files that do not exist + # Returns the proper response for files that do not exist def self.not_found resp resp.status = 404 resp.content = "File not found" end @@ -64,9 +63,10 @@ file = @manifest.find_by_path(path) resp = EventMachine::DelegatedHttpResponse.new(self) if file.is_a? ManifestDir file = @manifest.find_by_path(path+"/index.html") end + resp.content_type MIME::Types.type_for(path).first Server.handle_file(resp, file).send_response end end end