Table of Content
The Content-Disposition response header is an HTTP header field used to convey additional information about how to process the response payload, often indicating whether the content should be displayed inline in the browser, that it needs to be downloaded and saved locally, or simply providing a filename for download. It helps the server instruct the browser how to process different types of documents.
The syntax and structure take the form of
Content-Disposition: inline or
Content-Disposition: attachment, sometimes followed by a filesystem-safe filename in order to save the file.
Content-Disposition: inline Content-Disposition: attachment Content-Disposition: attachment; filename="filename.jpg"
The directives for the Content-Disposition header primarily include
inline: Specifies that the browser should display the content in the user's browser window.
attachment: Specifies that the browser should prompt the user to save the content to disk.
filename: If this directive is specified, the browser will save the file with the suggested filename, but without removing any dangerous customer-provided content.
Content-Disposition: attachment; filename="cool_pic.jpg"
In this example, when the browser processes this header it prompts the user to download the file
How to modify Content-Disposition header
ModHeader is a Chrome extension that allows you to change headers on requests and responses. By using ModHeader, users can modify the Content-Disposition header when making HTTP requests. Here is a step-by-step guide:
- Install the ModHeader extension from the Chrome Web Store.
- Open the developer tools panel. (Navigate to View > Developer > Developer Tools)
- Click on the ModHeader tab.
- In the
Response Headerssection, click
- In the
- In the
Valuefield, enter the desired value (e.g.,
This will modify all requests to include the new Content-Disposition header, which can be particularly useful when testing how your application handles different types of content-disposition scenarios.