Check IF_NONE_MATCH header for directory listings
This commit is contained in:
parent
bec9f7a6cc
commit
15196ca4b9
@ -75,9 +75,10 @@ module RemoteStorage
|
||||
end
|
||||
|
||||
def get_directory_listing(user, directory)
|
||||
# TODO check IF_NONE_MATCH header
|
||||
etag = redis.hget "rs_meta:#{user}:#{directory}/", "etag"
|
||||
|
||||
none_match = (server.env["HTTP_IF_NONE_MATCH"] || "").split(",").map(&:strip)
|
||||
server.halt 304 if none_match.include? etag
|
||||
|
||||
server.headers["Content-Type"] = "application/json"
|
||||
server.headers["ETag"] = %Q("#{etag}")
|
||||
|
@ -183,6 +183,13 @@ describe "App" do
|
||||
last_response.headers["ETag"].must_equal "\"bla\""
|
||||
end
|
||||
|
||||
it "responds with 304 when IF_NONE_MATCH header contains the ETag" do
|
||||
header "If-None-Match", "bla"
|
||||
get "/phil/food/"
|
||||
|
||||
last_response.status.must_equal 304
|
||||
end
|
||||
|
||||
it "contains all items in the directory" do
|
||||
get "/phil/food/"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user