aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <DeepDiver1975@users.noreply.github.com>2016-07-08 09:16:11 +0200
committerGitHub <noreply@github.com>2016-07-08 09:16:11 +0200
commitbf9524e3303649be379040e031f01de10d3104a6 (patch)
treeb1007b0256f71cddaa9c2914d595aa2939ff286b
parent7b92dd2cca9533a0dcde73d01e07b1ed2cdb3dae (diff)
downloadnextcloud-server-bf9524e3303649be379040e031f01de10d3104a6.tar.gz
nextcloud-server-bf9524e3303649be379040e031f01de10d3104a6.zip
[stable8.1] Set content type when downloading log file to force download in some browsers (#25382) (#25400)
-rw-r--r--settings/controller/logsettingscontroller.php1
-rw-r--r--tests/settings/controller/logsettingscontrollertest.php3
2 files changed, 4 insertions, 0 deletions
diff --git a/settings/controller/logsettingscontroller.php b/settings/controller/logsettingscontroller.php
index cae0d419e2b..4f3db00295b 100644
--- a/settings/controller/logsettingscontroller.php
+++ b/settings/controller/logsettingscontroller.php
@@ -103,6 +103,7 @@ class LogSettingsController extends Controller {
*/
public function download() {
$resp = new StreamResponse(\OC_Log_Owncloud::getLogFilePath());
+ $resp->addHeader('Content-Type', 'application/octet-stream');
$resp->addHeader('Content-Disposition', 'attachment; filename="owncloud.log"');
return $resp;
}
diff --git a/tests/settings/controller/logsettingscontrollertest.php b/tests/settings/controller/logsettingscontrollertest.php
index 60680ba4647..88d5d9bf93a 100644
--- a/tests/settings/controller/logsettingscontrollertest.php
+++ b/tests/settings/controller/logsettingscontrollertest.php
@@ -70,5 +70,8 @@ class LogSettingsControllerTest extends \Test\TestCase {
$response = $this->logSettingsController->download();
$this->assertInstanceOf('\OCP\AppFramework\Http\StreamResponse', $response);
+ $headers = $response->getHeaders();
+ $this->assertEquals('application/octet-stream', $headers['Content-Type']);
+ $this->assertEquals('attachment; filename="owncloud.log"', $headers['Content-Disposition']);
}
}