Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 31539eb0dbd4c98f9beeea89aae7cdec16003aad 1 parent bc1b73f
@rickenharp rickenharp authored bmarini committed
Showing with 2 additions and 1 deletion.
  1. +1 −1  lib/rack/gridfs/endpoint/base.rb
  2. +1 −0  test/gridfs_test.rb
View
2  lib/rack/gridfs/endpoint/base.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
1  test/gridfs_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.