Problems downloading csv with IE and https/SSL

In order to fix a problem with downloading CSV-files using Internet Explorer and https, I had to set some response headers to a stream resource.
(Problem is, that IE < 9 expects to “cache” the file before showing it in Excel)
According to a previous posting, one should use resource.getStream().setParameter() to add response header params.
So I did:

      resource.getStream().setParameter("Content-Disposition", "attachment;filename=\"" + downloadName + "\"");
      resource.getStream().setParameter("Cache-Control","no-store, no-cache, no-transform, must-revalidate, private");

By using fiddler (a great tool by the way to debug http traffic), I found out, that the response headers I set, were missing.

Analyzing the code of StreamResource.getStream(), i figured the problem was, that getStream() always returns a NEW
DownloadStream object, thus forgetting already set parameters.
Either the Download Stream has to be kept and reused, or the parameters HashMap has to be moved from DownloadStream to

I fixed the stuff by subclassing StreamResource:

  private DownloadStream downloadStream;

  public COIStreamResource(StreamSource streamSource, String filename, Application application)
    super(streamSource, filename, application);

  public DownloadStream getStream()
    final StreamSource ss = getStreamSource();
    if (ss == null)
      return null;
    if ( downloadStream == null)
      downloadStream = new DownloadStream(ss.getStream(), getMIMEType(), getFilename());

    return downloadStream;

Any other suggestions on how to fix the problem?