Set the Content-Disposition
header on the response. For example, the headers:
Content-Disposition: attachment; filename="filename.csv"
...will cause a browser to download the HTTP response entity as a file named "filename.csv". You probably want a MIME type too, which will look like this:
Content-Type: application/csv
Content-Disposition: attachment; filename="filename.csv"