Skip to content
Permalink
Browse files Browse the repository at this point in the history
[stable9] Set content-type to "application/octet-stream"
Some browsers such as Firefox on Microsoft Windows otherwise do offer to open the file directly which is kinda silly.

Backport of #258
  • Loading branch information
LukasReschke committed Jun 30, 2016
1 parent 95f6dd9 commit 94975af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion settings/controller/logsettingscontroller.php
Expand Up @@ -103,7 +103,8 @@ public function getEntries($count=50, $offset=0) {
*/
public function download() {
$resp = new StreamResponse(\OC_Log_Owncloud::getLogFilePath());
$resp->addHeader('Content-Disposition', 'attachment; filename="owncloud.log"');
$resp->addHeader('Content-Type', 'application/octet-stream');
$resp->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"');
return $resp;
}
}
6 changes: 5 additions & 1 deletion tests/settings/controller/logsettingscontrollertest.php
Expand Up @@ -11,6 +11,7 @@

use \OC\Settings\Application;
use OC\Settings\Controller\LogSettingsController;
use OCP\AppFramework\Http\StreamResponse;

/**
* @package OC\Settings\Controller
Expand Down Expand Up @@ -69,6 +70,9 @@ public function logLevelData() {
public function testDownload() {
$response = $this->logSettingsController->download();

$this->assertInstanceOf('\OCP\AppFramework\Http\StreamResponse', $response);
$expected = new StreamResponse(\OC_Log_Owncloud::getLogFilePath());
$expected->addHeader('Content-Type', 'application/octet-stream');
$expected->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"');
$this->assertEquals($expected, $response);
}
}

0 comments on commit 94975af

Please sign in to comment.