Allow for weak ETAGs with leading quote
The remoteStorage client currently surrounds all ETAGs with quotes, so instead of W\"etag" it looks like "W\"etag".
This commit is contained in:
@@ -52,7 +52,7 @@ module RemoteStorage
|
||||
|
||||
set_response_headers(res)
|
||||
|
||||
none_match = (server.env["HTTP_IF_NONE_MATCH"] || "").gsub(/^W\//, "").split(",").map(&:strip)
|
||||
none_match = (server.env["HTTP_IF_NONE_MATCH"] || "").gsub(/^"?W\//, "").split(",").map(&:strip)
|
||||
server.halt 304 if none_match.include? %Q("#{res.headers[:etag]}")
|
||||
|
||||
return res.body
|
||||
@@ -71,7 +71,7 @@ module RemoteStorage
|
||||
|
||||
server.headers["Content-Type"] = "application/ld+json"
|
||||
|
||||
none_match = (server.env["HTTP_IF_NONE_MATCH"] || "").gsub(/^W\//, "").split(",").map(&:strip)
|
||||
none_match = (server.env["HTTP_IF_NONE_MATCH"] || "").gsub(/^"?W\//, "").split(",").map(&:strip)
|
||||
|
||||
if etag
|
||||
server.halt 304 if none_match.include? %Q("#{etag}")
|
||||
@@ -139,7 +139,7 @@ module RemoteStorage
|
||||
url = url_for_key(user, directory, key)
|
||||
|
||||
if required_match = server.env["HTTP_IF_MATCH"]
|
||||
unless required_match.gsub(/^W\//, "") == %Q("#{existing_metadata["e"]}")
|
||||
unless required_match.gsub(/^"?W\//, "") == %Q("#{existing_metadata["e"]}")
|
||||
server.halt 412, "Precondition Failed"
|
||||
end
|
||||
end
|
||||
@@ -187,7 +187,7 @@ module RemoteStorage
|
||||
existing_metadata = redis.hgetall "rs:m:#{user}:#{directory}/#{key}"
|
||||
|
||||
if required_match = server.env["HTTP_IF_MATCH"]
|
||||
unless required_match.gsub(/^W\//, "") == %Q("#{existing_metadata["e"]}")
|
||||
unless required_match.gsub(/^"?W\//, "") == %Q("#{existing_metadata["e"]}")
|
||||
server.halt 412, "Precondition Failed"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user