Permalink
Browse files

Send Etag header in 304 response, according to HTTP 1.1 specs

  • Loading branch information...
1 parent bc1b73f commit 31539eb0dbd4c98f9beeea89aae7cdec16003aad @rickenharp rickenharp committed with bmarini Dec 18, 2010
Showing with 2 additions and 1 deletion.
  1. +1 −1 lib/rack/gridfs/endpoint/base.rb
  2. +1 −0 test/gridfs_test.rb
@@ -33,7 +33,7 @@ def gridfs_request(id, request)
grid = Mongo::GridFileSystem.new(db)
file = grid.open(id, 'r')
if request.env['If-None-Match'] == file.files_id.to_s || request.env['If-Modified-Since'] == file.upload_date.httpdate
- [304, {'Content-Type' => 'text/plain'}, ['Not modified']]
+ [304, {'Content-Type' => 'text/plain', 'Etag' => file.files_id.to_s}, ['Not modified']]
else
[200, headers(file), [file.read]]
end
View
@@ -160,6 +160,7 @@ def app; setup_app end
gridfile = Mongo::Grid.new(db).get(image_id)
get "/gridfs/3wolfmoon.jpg", nil, {'If-Modified-Since' => gridfile.upload_date.httpdate}
assert_equal 304, last_response.status
+ assert_equal gridfile.files_id.to_s, last_response.headers['Etag']
end
end

0 comments on commit 31539eb

Please sign in to comment.