Skip to content

Commit

Permalink
Follow redirects for ls (#103)
Browse files Browse the repository at this point in the history
* adds trailing slash for ls

* black

* follow_redirects in ls
  • Loading branch information
normanrz authored Apr 28, 2022
1 parent 6c67b9e commit 460a021
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/webdav4/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ def join_url(self, path: str, add_trailing_slash: bool = False) -> URL:
)

def propfind(
self, path: str, data: str = None, headers: "HeaderTypes" = None
self,
path: str,
data: str = None,
headers: "HeaderTypes" = None,
follow_redirects: bool = False,
) -> "MultiStatusResponse":
"""Returns properties of the specific resource by propfind request."""
call = wrap_fn(
Expand All @@ -309,6 +313,7 @@ def propfind(
path,
content=data,
headers=headers,
follow_redirects=follow_redirects,
)
http_resp = self.with_retry(call)
return parse_multistatus_response(http_resp)
Expand Down Expand Up @@ -502,7 +507,9 @@ def ls( # pylint: disable=invalid-name
(non-collection), ls will return the file entry/details.
Otherwise, it will raise an error.
"""
result = self.propfind(path, headers={"Depth": "1"})
result = self.propfind(
path, headers={"Depth": "1"}, follow_redirects=True
)
responses = result.responses

url = self.join_url(path)
Expand Down

0 comments on commit 460a021

Please sign in to comment.