Friday, April 24, 2009

Internet Explorer Download Problem When Using HTTPS


If you develop a secure web application and have a downloads page, you may find that your page doesn't work correctly in Internet Explorer. You may receive some sort of error message even though the document is available.
The solution for this problem is to set the following response headers to empty string (same as remove these headers):
- Pragma & Cache-Control.

Here you can find also the way I've done this in wicket:


add(new StatelessLink("downloadAttachmentLink") {
@Override
public void onClick() {
RequestCycle.get().setRequestTarget(
new ResourceStreamRequestTarget(new WebExternalResourceStream("/downloads/" + getAttachmentName())) {
@Override
protected void configure(final RequestCycle requestCycle, final Response response,
final IResourceStream resourceStream) {
final WebResponse webResponse = (WebResponse) response;
//remove these headers to make it work!
webResponse.setHeader("Pragma", "");
webResponse.setHeader("Cache-Control", "");
webResponse.setAttachmentHeader(getAttachmentName());
}
});
}
});


Links: