Check IF_NONE_MATCH header for directory listings
This commit is contained in:
parent
bec9f7a6cc
commit
15196ca4b9
@ -75,9 +75,10 @@ module RemoteStorage
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_directory_listing(user, directory)
|
def get_directory_listing(user, directory)
|
||||||
# TODO check IF_NONE_MATCH header
|
|
||||||
etag = redis.hget "rs_meta:#{user}:#{directory}/", "etag"
|
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["Content-Type"] = "application/json"
|
||||||
server.headers["ETag"] = %Q("#{etag}")
|
server.headers["ETag"] = %Q("#{etag}")
|
||||||
|
@ -183,6 +183,13 @@ describe "App" do
|
|||||||
last_response.headers["ETag"].must_equal "\"bla\""
|
last_response.headers["ETag"].must_equal "\"bla\""
|
||||||
end
|
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
|
it "contains all items in the directory" do
|
||||||
get "/phil/food/"
|
get "/phil/food/"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user