When you send out a Content-Disposition header in PHP, you might end up in some situations with the wrong HTTP status code. Simply adding ",true, 200" as arguments to the header function resolves this issue.
<?php header('Content-Disposition: attachment; filename="'.$filename.'.csv";', true, 200);