Skip to content

Commit

Permalink
Controller#propfind: Handle the empty request body case.
Browse files Browse the repository at this point in the history
Per RFC 2518 §8.1: An empty PROPFIND request body must be treated as a
request for the names and values of all properties.

Signed-off-by: Alex Zepeda <[email protected]>
  • Loading branch information
inferiorhumanorgans committed Aug 26, 2013
1 parent ab3404c commit 14502d2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/dav4rack/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ def propfind
unless(resource.exist?)
NotFound
else
unless(request_document.xpath("//#{ns}propfind/#{ns}allprop").empty?)
# Per RFC 2518 §8.1
# An empty PROPFIND request body must be treated as a request for the names and values of all properties.
if !request_document.xpath("//#{ns}propfind/#{ns}allprop").empty? or (request.content_length == '0')
properties = resource.properties
else
properties = (
Expand All @@ -187,8 +189,9 @@ def propfind

to_element_hash(item)
}

# We shouldn't ever be here.
raise BadRequest if properties.empty?
properties = resource.properties if properties.empty?
end
multistatus do |xml|
find_resources.each do |resource|
Expand Down

0 comments on commit 14502d2

Please sign in to comment.