How do you set a response header to indicate the content should be downloaded as a file?

  • response.setHeader("Content-Disposition", "attachment; filename=example.txt");
  • response.setHeader("Content-Encoding", "gzip");
  • response.setHeader("Content-Transfer-Encoding", "binary");
  • response.setHeader("Content-Type", "application/octet-stream");
To indicate that the content should be downloaded as a file, you can use the response.setHeader("Content-Disposition", "attachment; filename=example.txt"); method.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *