[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 https://github.com/nextcloud/server/pull/258
This commit is contained in:
Lukas Reschke 2016-06-30 13:04:54 +02:00
parent 95f6dd909b
commit 94975af6db
No known key found for this signature in database
GPG Key ID: 9AB0ADB949B6898C
2 changed files with 7 additions and 2 deletions

View File

@ -103,7 +103,8 @@ class LogSettingsController extends Controller {
*/
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;
}
}

View File

@ -11,6 +11,7 @@ namespace Test\Settings\Controller;
use \OC\Settings\Application;
use OC\Settings\Controller\LogSettingsController;
use OCP\AppFramework\Http\StreamResponse;
/**
* @package OC\Settings\Controller
@ -69,6 +70,9 @@ class LogSettingsControllerTest extends \Test\TestCase {
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);
}
}