Skip to content

Commit

Permalink
Add X-Accel-Buffering header to downloads
Browse files Browse the repository at this point in the history
Signed-off-by: Unpublished <unpublished@gmx.net>
  • Loading branch information
Unpublished committed Apr 13, 2021
1 parent 23b8e4a commit a822317
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response)
$response->addHeader('OC-Checksum', $checksum);
}
}
$response->addHeader('X-Accel-Buffering', 'no');
}

/**
Expand Down
7 changes: 5 additions & 2 deletions apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,12 @@ public function testDownloadHeaders($isClumsyAgent, $contentDispositionHeader) {
->willReturn($isClumsyAgent);

$response
->expects($this->once())
->expects($this->exactly(2))
->method('addHeader')
->with('Content-Disposition', $contentDispositionHeader);
->withConsecutive(
['Content-Disposition', $contentDispositionHeader],
['X-Accel-Buffering', 'no']
);

$this->plugin->httpGet($request, $response);
}
Expand Down
1 change: 1 addition & 0 deletions lib/private/Streamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function __construct(IRequest $request, int $size, int $numberOfFiles) {
* @param string $name
*/
public function sendHeaders($name) {
header('X-Accel-Buffering: no');
$extension = $this->streamerInstance instanceof ZipStreamer ? '.zip' : '.tar';
$fullName = $name . $extension;
$this->streamerInstance->sendHeaders($fullName);
Expand Down
1 change: 1 addition & 0 deletions lib/private/legacy/OC_Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private static function sendHeaders($filename, $name, array $rangeArray) {
}
}
header('Content-Type: '.$type, true);
header('X-Accel-Buffering: no');
}

/**
Expand Down

0 comments on commit a822317

Please sign in to comment.