Skip to content

Commit 57792e5

Browse files
mkovaluafelliott
authored andcommitted
fix broken owncloud downloads
* owncloud gzips some file types (yml, json). Send the Accept-Encoding: identity header allow to return actual file size not archived to read it properly * update owncloud test_download_range to work with new download headers changes
1 parent 61ee265 commit 57792e5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tests/providers/owncloud/test_provider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ async def test_download_range(self, provider, file_metadata):
176176
assert result.partial
177177
content = await result.response.read()
178178
assert content == b'sq'
179-
assert aiohttpretty.has_call(method='GET', uri=url, headers={'Range': 'bytes=0-1'})
179+
headers={'Range': 'bytes=0-1', 'Accept-Encoding': 'identity'}
180+
assert aiohttpretty.has_call(method='GET', uri=url, headers=headers)
180181

181182
@pytest.mark.asyncio
182183
@pytest.mark.aiohttpretty

waterbutler/providers/owncloud/provider.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ async def download(self, path, accept_url=False, range=None, **kwargs):
147147
'got_accept_url': accept_url is False,
148148
'got_range': range is not None,
149149
})
150+
# Accept-Encoding: identity header tells owncloud not to zip certain text formats
150151
download_resp = await self.make_request(
151152
'GET',
152153
self._webdav_url_ + path.full_path,
154+
headers={'Accept-Encoding': 'identity'},
153155
range=range,
154156
expects=(200, 206,),
155157
throws=exceptions.DownloadError,

0 commit comments

Comments
 (0)