Kiss A simpler, smarter web application framework for Ruby

Kiss::StaticFile Subclass of Object

Methods

Public Class Methods

new(path,mime_type = nil) source

Not documented

    # File lib/kiss/static_file.rb, line 3
    def initialize(path,mime_type = nil)
      @path = path
      @mime_type = mime_type
    end
    

Public Instance Methods

each() {|part| ...} source

Not documented

    # File lib/kiss/static_file.rb, line 23
    def each
      File.open(@path, "rb") { |file|
        while part = file.read(8192)
          yield part
        end
      }
    end
    
finish() source

Not documented

    # File lib/kiss/static_file.rb, line 8
    def finish
      ext = File.extname(@path)[1..-1]
      
      if File.file?(@path) && File.readable?(@path)
        [200, {
           "Last-Modified"  => File.mtime(@path).rfc822,
           "Content-Type"   => @mime_type || Kiss.mime_type(ext) || "text/plain",
           "Content-Length" => File.size(@path).to_s
         }, self]
      else
        return [404, {"Content-Type" => "text/plain"},
                ["File not found: #{@path}\n"]]
      end
    end
    

Disabled; run with $DEBUG to generate this.