Skip to content

Commit

Permalink
[stable8.1] Set content type when downloading log file to force downl…
Browse files Browse the repository at this point in the history
…oad in some browsers (#25382)
  • Loading branch information
Vincent Petry authored and DeepDiver1975 committed Jul 6, 2016
1 parent 7b92dd2 commit 044ee07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions settings/controller/logsettingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function getEntries($count=50, $offset=0) {
*/
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;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/settings/controller/logsettingscontrollertest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,8 @@ public function testDownload() {
$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']);
}
}

0 comments on commit 044ee07

Please sign in to comment.