Open Bug 517846 Opened 14 years ago Updated 4 months ago

content-disposition doesn't work for streamed response

Categories

(Firefox :: File Handling, defect)

3.5 Branch
x86
Windows XP
defect

Tracking

()

UNCONFIRMED

People

(Reporter: askoro, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3

Trying to force the File Save Dialog through HTTP header in JSP pops-up the Dialog without the file name. Pressing either the OK or the Cancel button want close the dialog. Obviously no data is downloaded. Works perfectly in IE7. The download JSP used is:
<%@ page language = "java" %>
<%@ page import   = "org.apache.commons.io.FileUtils" %>
<%@ page import   = "java.io.File" %>
<%
    String              dirName     = request.getParameter("dir");  // relative to the application directory terminated with a forward slash (/)
    String              fileName    = request.getParameter("file");
    File                f           = new File(application.getRealPath(dirName+fileName));
    long                fSize       = f.length();
    byte[]              fContent    = FileUtils.readFileToByteArray(f);
    ServletOutputStream os          = response.getOutputStream();
    response.setContentType("application/download");
    response.setHeader("Content-Length", Long.toString(fSize));
    response.setHeader("Content-Disposition", "attachment; filename=\""+fileName+"\";");
    os.write(fContent);
    os.flush();
    os.close();
%>


Reproducible: Always

Steps to Reproduce:
1. Have a page with links to files on the server and call download.jsp?dir="files directory path"&file="files name"
2. On executing the link the File Save Dialog comes up with nothing in it
3. Try closing it with OK/Cancel buttons
Actual Results:  
In valid File Save Dialog

Expected Results:  
File Save Dialog with the name specified in the Content-Disposition header as a suggestion and ability to Open/Save the file.

Please note that the file name is enclosed in double quotes even if it has no embedded spaces.
Version: unspecified → 3.5 Branch
Just had a try with a normal (non-modal) window and it works correctly but it still doesn't work from inside a modal window opened with window.showModalDialog(...)
Is this still valid? A bit laborious to test as it requires a JSP set up. It seems JSP is fading away anyways.
QA Whiteboard: qa-not-actionable

In the process of migrating remaining bugs to the new severity system, the severity for this bug cannot be automatically determined. Please retriage this bug using the new severity system.

Severity: major → --
You need to log in before you can comment on or make changes to this bug.