Send ETag header with 304 response as well

This commit is contained in:
Garret Alfert 2013-11-16 13:54:30 +01:00
parent af270bc27c
commit 088cd2677c
3 changed files with 6 additions and 4 deletions

View File

@ -40,12 +40,12 @@ module RemoteStorage
def get_data(user, directory, key)
object = data_bucket.get("#{user}:#{directory}:#{key}")
server.halt 304 if server.env["HTTP_IF_NONE_MATCH"] == object.etag
server.headers["Content-Type"] = object.content_type
server.headers["Last-Modified"] = last_modified_date_for(object)
server.headers["ETag"] = object.etag
server.halt 304 if server.env["HTTP_IF_NONE_MATCH"] == object.etag
if binary_key = object.meta["binary_key"]
object = cs_binary_bucket.files.get(binary_key[0])
@ -70,14 +70,14 @@ module RemoteStorage
def get_directory_listing(user, directory)
directory_object = directory_bucket.get("#{user}:#{directory}")
server.halt 304 if server.env["HTTP_IF_NONE_MATCH"] == directory_object.etag
timestamp = directory_object.data.to_i
timestamp /= 1000 if timestamp.to_s.length == 13
server.headers["Content-Type"] = "application/json"
server.headers["Last-Modified"] = Time.at(timestamp).to_s(:rfc822)
server.headers["ETag"] = directory_object.etag
server.halt 304 if server.env["HTTP_IF_NONE_MATCH"] == directory_object.etag
listing = directory_listing(user, directory)
return listing.to_json

View File

@ -80,6 +80,7 @@ describe "Directories" do
last_response.status.must_equal 304
last_response.body.must_be_empty
last_response.headers["ETag"].must_equal @etag
end
it "responds normally when it does not match the current ETag" do

View File

@ -89,6 +89,7 @@ describe "App with Riak backend" do
last_response.status.must_equal 304
last_response.body.must_be_empty
last_response.headers["ETag"].must_equal @etag
end
it "responds normally when it does not match the current ETag" do