-
Notifications
You must be signed in to change notification settings - Fork 113
Description
Hello!
When using the latest version of easywebdav,
easywebdav 1.0.7
requests 1.1.0
webdav server: mod_dav, apache2
ubuntu 12.10
I have a problem using downloading files. When doing a download (by calling the download() method), the file is created on the local machine with the correct name, but the file is empty (zero size).
When looking at the code I can see response.raw is used as an input to shutil.copyfileobj(). However, I think that the documentation for requests states that 'stream=True' must be used in the call to session.request for .raw to be valid (http://docs.python-requests.org/en/latest/api/):
"raw = None
File-like object representation of response (for advanced usage).
Requires that 'stream=True' on the request."
I have tried setting stream=True (line 77 in client.py). and the received file then contains data! However, when looking at the header I can see that my webdav server gzip'ing the files, so the files downloaded have to be unszipped.
*** client-new.py 2013-02-20 08:27:29.941967542 +0100
--- client-org.py 2013-02-18 14:17:59.114443000 +0100
***************
*** 76,78 ****
url = self._get_url(path)
! response = self.session.request(method, url, allow_redirects=False, stream=True, **kwargs)
if isinstance(expected_code, Number) and response.status_code != expected_code \
--- 76,78 ----
url = self._get_url(path)
! response = self.session.request(method, url, allow_redirects=False, **kwargs)
if isinstance(expected_code, Number) and response.status_code != expected_code \
To get around this problem I have just uncommented the 'f.write(response.content)' on line 126 in client.py (and added a comment to 'shutil.copyfileobj(response.raw, f)' on line 127).
As far as I can see using response.raw and something like shutil.copyfileobj() is however necessary to be able to download really large files.