Skip to content

Commit

Permalink
Make Rack::File use RFC 2616 HTTP Date/Time format for Last-Modified
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Kubb committed Jun 27, 2008
1 parent 2e3c3ad commit 7523300
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rack/file.rb
Expand Up @@ -31,7 +31,7 @@ def _call(env)

if F.file?(@path) && F.readable?(@path)
[200, {
"Last-Modified" => F.mtime(@path).rfc822,
"Last-Modified" => F.mtime(@path).httpdate,
"Content-Type" => MIME_TYPES[ext] || "text/plain",
"Content-Length" => F.size(@path).to_s
}, self]
Expand Down
12 changes: 11 additions & 1 deletion test/spec_rack_file.rb
Expand Up @@ -15,7 +15,17 @@
res.should.be.ok
res.should =~ /ruby/
end


specify "sets Last-Modified header" do
res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))).
get("/cgi/test")

path = File.join(DOCROOT, "/cgi/test")

res.should.be.ok
res["Last-Modified"].should.equal File.mtime(path).httpdate
end

specify "serves files with URL encoded filenames" do
res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))).
get("/cgi/%74%65%73%74") # "/cgi/test"
Expand Down

0 comments on commit 7523300

Please sign in to comment.