diff --git a/lib/remote_storage/swift.rb b/lib/remote_storage/swift.rb index ceb65a4..216b7ab 100644 --- a/lib/remote_storage/swift.rb +++ b/lib/remote_storage/swift.rb @@ -75,10 +75,12 @@ module RemoteStorage end def get_directory_listing(user, directory) - # TODO add ETag header # TODO check IF_NONE_MATCH header + etag = redis.hget "rs_meta:#{user}:#{directory}/", "etag" + server.headers["Content-Type"] = "application/json" + server.headers["ETag"] = %Q("#{etag}") listing = { "@context" => "http://remotestorage.io/spec/folder-description", diff --git a/spec/swift/app_spec.rb b/spec/swift/app_spec.rb index 924a259..877b0f7 100644 --- a/spec/swift/app_spec.rb +++ b/spec/swift/app_spec.rb @@ -176,6 +176,13 @@ describe "App" do describe "directory listings" do + it "has an ETag in the header" do + get "/phil/food/" + + last_response.status.must_equal 200 + last_response.headers["ETag"].must_equal "\"bla\"" + end + it "contains all items in the directory" do get "/phil/food/"