diff options
author | Dan Kubb <dan.kubb@autopilotmarketing.com> | 2008-06-27 09:44:38 -0700 |
---|---|---|
committer | Dan Kubb <dan.kubb@autopilotmarketing.com> | 2008-06-27 09:44:38 -0700 |
commit | 75233001e0c6a2a0e95c4343c29634d8048dc9c2 (patch) | |
tree | 2f7451bc4006d10cdf15179c5e46578dbb6b0f1a | |
parent | 2e3c3adc0df92fcd41b32feb4b64bfaae9664385 (diff) | |
download | rack-75233001e0c6a2a0e95c4343c29634d8048dc9c2.tar.gz |
Make Rack::File use RFC 2616 HTTP Date/Time format for Last-Modified
-rw-r--r-- | lib/rack/file.rb | 2 | ||||
-rw-r--r-- | test/spec_rack_file.rb | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/rack/file.rb b/lib/rack/file.rb index 92665d31..7538fd69 100644 --- a/lib/rack/file.rb +++ b/lib/rack/file.rb @@ -31,7 +31,7 @@ module Rack 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] diff --git a/test/spec_rack_file.rb b/test/spec_rack_file.rb index 90e29405..0707d03c 100644 --- a/test/spec_rack_file.rb +++ b/test/spec_rack_file.rb @@ -15,7 +15,17 @@ context "Rack::File" do 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" |