title: http response getting printed in browser if "Content-type" and "content-disposition" are set after writing in http "response" outputstream
body: <p>I have a use-case where I have to set "Content-type" and "content-disposition" after writing in http response outputstream instead of downloading as a file. Following sample code depicts the case :-</p>
  
  <pre><code>@Context
  HttpServletResponse response;
  
  @GET
  @Produces(MediaType.TEXT_PLAIN)
  public String downloadFile() throws IOException {
  
      File file = new File("/var/tmp/input.txt");
      FileInputStream fs = new FileInputStream(file);
  
      copyStream(fs, response.getOutputStream());
  
      response.setContentType("text/csv");
      response.setHeader("Content-Disposition","attachment;filename=\"" + "ts.csv" + "\"");
  
      return "";
  }
  </code></pre>
  
  <p>When I give a small input (input.txt file), my browser gives me option to download it but when the input is large, it prints the file content directly in the browser tab.</p>
  
  <p>Any pointers what I can do such that it gives a file downoad option for large input as well?</p>