Send "Precondition Failed" message body with 412 responses

This commit is contained in:
Garret Alfert
2016-06-02 18:49:20 +02:00
parent cc91b5c4cd
commit c897959029
2 changed files with 99 additions and 3 deletions

View File

@@ -139,10 +139,10 @@ module RemoteStorage
url = url_for_key(user, directory, key)
if required_match = server.env["HTTP_IF_MATCH"]
server.halt 412 unless required_match == %Q("#{existing_metadata["e"]}")
server.halt 412, "Precondition Failed" unless required_match == %Q("#{existing_metadata["e"]}")
end
if server.env["HTTP_IF_NONE_MATCH"] == "*"
server.halt 412 unless existing_metadata.empty?
server.halt 412, "Precondition Failed" unless existing_metadata.empty?
end
res = do_put_request(url, data, content_type)
@@ -178,7 +178,7 @@ module RemoteStorage
existing_metadata = redis.hgetall "rs:m:#{user}:#{directory}/#{key}"
if required_match = server.env["HTTP_IF_MATCH"]
server.halt 412 unless required_match == %Q("#{existing_metadata["e"]}")
server.halt 412, "Precondition Failed" unless required_match == %Q("#{existing_metadata["e"]}")
end
do_delete_request(url)