lib/rack/file.rb in rack-0.9.1 vs lib/rack/file.rb in rack-1.0.0
- old
+ new
@@ -1,6 +1,7 @@
require 'time'
+require 'rack/utils'
require 'rack/mime'
module Rack
# Rack::File serves files below the +root+ given, according to the
# path info of the Rack request.
@@ -10,10 +11,12 @@
class File
attr_accessor :root
attr_accessor :path
+ alias :to_path :path
+
def initialize(root)
@root = root
end
def call(env)
@@ -55,10 +58,10 @@
def serving
if size = F.size?(@path)
body = self
else
body = [F.read(@path)]
- size = body.first.size
+ size = Utils.bytesize(body.first)
end
[200, {
"Last-Modified" => F.mtime(@path).httpdate,
"Content-Type" => Mime.mime_type(F.extname(@path), 'text/plain'),