You have already answered your own question! Adjust the mime-type to something other than is configured on the windows client by default and it will force a download.
The key to the open/download issue is the difference in the way that IE deals with mime-types. When your Perl app returns content, IE has no choice but to believe the mime-type header supplied. IE compares the mime-type supplied in the content header and acts according to the settings for that mime-type.
Your application (e.g. /myapp/download.cgi?file1) returns a file (stream of bytes) which just happens to be a Word document:
- Setting the Content-type header to application/msword will cause IE to recognise the stream of bytes as a Word document and take the default action. This is probably loading it up in the same window
- Setting the mime-type to application/msword-download will cause IE to look for information relating to the application/msword-download mime-type and take action accordingly. Since there is no mime-type information set, IE will take the default action of asking you to save or open the file.
The mime-type / content / action relationship is configured in the registry of the Windows client. The HKCR/.extension keys map the mime-type to a document extension.
HKCR\.doc
"Content Type"="application/msword"
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.