Content-Disposition

The Content-Disposition header, which is borrowed from RFC 1806, allows for some additional flexibility with regard to media types. The most common use of this header is to force a filename for a file that should be saved rather than rendered. An example of this use is the following:

Content-Disposition: attachment; filename=”example.pdf” 

This indicates that the user should be prompted to download the file and that the pre-filled filename should be example.pdf.

Note

This technique can also resolve the browser flaw mentioned previously, where the file extension is used to determine media type instead of the Content-Type entity header. Thus, Content-Disposition can allow the true filename of the resource to be overridden. ...

Get HTTP Developer’s Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.