DownloadStream wrongly encodes filename?

hey there,

not sure if this is really true, but I expected DownloadStream#getContentDispositionFilename(String) to encode spaces in filenames with %20 rather than +. However, this is of course related because of using java.net.URLEncoder as it does a application/x-www-form-urlencoded which says: Space characters are replaced by `+’

The effect is, that at least Firefox browser suggests to download the file file with spaces.txt with name file+with+spaces.txt.

Unfortunately, I cannot set the Content-Disposition parameter by hand as StreamResource#getStream() always returns a new instance which makes

treamResource streamResource = new StreamResource(source, filename);
String cd = "attachment; " + DownloadStream.getContentDispositionFilename(filename);
streamResource.getStream().setParameter(DownloadStream.CONTENT_DISPOSITION, cd.replace("+", "%20"));

senseless.

Do you have any ideas?

Some links from my research:

Note: I do not have problems with this:
http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download

The only way I found to cope with that issue is to override the
handleConnectorRequest
method and in there to call my own
getContentDispositionFilename
-method instead of the original method of class DownloadStream.

The method looks as follows:

public String getContentDispositionFilename() { String filename = onDemandStreamResource.getFilename(); String filenameNoBlanks = filename.replace(" ", "%20"); // replace blanks with %20 for firefox, chrome and ie don't need that return String.format("filename=\"%s\"; filename*=utf-8\'\'%s", new Object[]{filename, filenameNoBlanks}); }

Instead of url encoding the filename as done in the original method here only blanks are replaced by “%20” for the “filename*=utf-8”-part. In chrome and IE it seems to work well even with blanks, however, Firefox can not read the filename if it contains blanks.