Skip to content

Commit

Permalink
Merge pull request #175 from mahngiel/header-content-type-csv
Browse files Browse the repository at this point in the history
Change Output header Content-Type to text/csv
  • Loading branch information
nyamsprod authored Sep 1, 2016
2 parents 7f8b31e + b61b7d6 commit fa9b377
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Config/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function output($filename = null)
{
if (null !== $filename) {
$filename = filter_var($filename, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
header('Content-Type: application/octet-stream');
header('Content-Type: text/csv');
header('Content-Transfer-Encoding: binary');
header("Content-Disposition: attachment; filename=\"$filename\"");
}
Expand Down
5 changes: 4 additions & 1 deletion test/CsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ public function testOutputHeaders()
}
$this->csv->output('test.csv');
$headers = \xdebug_get_headers();
$this->assertSame($headers[0], 'Content-Type: application/octet-stream');

// Due to the variety of ways the xdebug expresses Content-Type of text files,
// we cannot count on complete string matching.
$this->assertContains('content-type: text/csv', strtolower($headers[0]));
$this->assertSame($headers[1], 'Content-Transfer-Encoding: binary');
$this->assertSame($headers[2], 'Content-Disposition: attachment; filename="test.csv"');
}
Expand Down

0 comments on commit fa9b377

Please sign in to comment.