diff --git a/src/Config/Output.php b/src/Config/Output.php index 27221d6f..2e8bb152 100644 --- a/src/Config/Output.php +++ b/src/Config/Output.php @@ -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\""); } diff --git a/test/CsvTest.php b/test/CsvTest.php index 32115fb8..f25a430a 100644 --- a/test/CsvTest.php +++ b/test/CsvTest.php @@ -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"'); }