Skip to content

Commit 82bd176

Browse files
committed
fix(zip): Fix warning when downloading Zip file
The HEAD request, create a GET subrequest which is not compatible with the ZIP plugin since the ZIP plugin is directly streaming the content to php://output, so we were sending the content in a HEAD request and creating the ZIP twice and this was creating various warning in logs too. Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent b83b869 commit 82bd176

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ protected function streamNode(Streamer $streamer, NcNode $node, string $rootPath
9191
* It is possible to filter / limit the files that should be downloaded,
9292
* either by passing (multiple) `X-NC-Files: the-file` headers
9393
* or by setting a `files=JSON_ARRAY_OF_FILES` URL query.
94-
*
95-
* @return false|null
9694
*/
9795
public function handleDownload(Request $request, Response $response): ?bool {
96+
if ($request->getHeader('X-Sabre-Original-Method') === 'HEAD') {
97+
return null;
98+
}
9899
$node = $this->tree->getNodeForPath($request->getPath());
99100
if (!($node instanceof Directory)) {
100101
// only handle directories
@@ -183,11 +184,12 @@ public function handleDownload(Request $request, Response $response): ?bool {
183184
}
184185

185186
/**
186-
* Tell sabre/dav not to trigger it's own response sending logic as the handleDownload will have already send the response
187-
*
188-
* @return false|null
187+
* Tell sabre/dav not to trigger its own response sending logic as the handleDownload will have already sent the response
189188
*/
190189
public function afterDownload(Request $request, Response $response): ?bool {
190+
if ($request->getHeader('X-Sabre-Original-Method') === 'HEAD') {
191+
return null;
192+
}
191193
$node = $this->tree->getNodeForPath($request->getPath());
192194
if (!($node instanceof Directory)) {
193195
// only handle directories

0 commit comments

Comments
 (0)