Reputation: 2451
I have a Struts action, which is writing to HttpServletResponse
as follows. Code only works for HTTP, but not for HTTPS.
BufferedInputStream in = null;
try {
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\";");
// set response headers
response.setContentLength(fileData.length);
response.setContentType("application/octet-stream");
//BUFFER
int bufferSize = 2 * 1024 * 1024;
in = new BufferedInputStream(new ByteArrayInputStream(fileData), bufferSize);
byte[] buffer = new byte[bufferSize];
int len = 0;
// Loop through the input file and get the data chunks...
while ((len = in.read(buffer, 0, bufferSize)) != -1) {
response.getOutputStream().write(buffer, 0, len);
}
} catch (Exception e) {
throw new SystemException(e.getMessage());
} finally {
response.getOutputStream().flush();
response.getOutputStream().close();
}
Server is Weblogic 10 (does it matter?). Entire web application works with HTTPS, except of the file download. It does work with Chrome and FF, but not with IE 8/9. The following message is displayed in an alert box
Windows cannot find 'https://xxxxxxx'
Upvotes: 1
Views: 1629
Reputation: 1108712
This is a known IE-specific problem, see also the Microsoft support site: Internet Explorer is unable to open Office documents from an SSL Web site. To fix it, you need to explicitly set the following headers on the response:
response.setHeader("Cache-Control", "public");
response.setHeader("Pragma", "public");
Upvotes: 4