How to override the Content-Type response header to view a file instead of downloading it
To make Chrome, Edge or Firefox show a file in the tab instead of downloading it, add a response header named Content-Type in HeaderDial with the value text/plain (or application/json), and limit it to that file's URL. In Chrome 159 and Firefox 158 a file the server sent as application/octet-stream then opened as text. If the server also sends Content-Disposition: attachment, the file still downloads until you remove that header as well. The same override can unblock a script that a server sends as text/plain with X-Content-Type-Options: nosniff.
Why the browser downloads instead of showing
Two response headers decide it:
| Header | Example | Effect on a page load |
|---|---|---|
Content-Type | application/octet-stream | A type the browser cannot display, so it downloads the file. text/plain, text/html, application/json and images are displayed. |
Content-Disposition | attachment; filename="report.csv" | Downloads the file whatever its type. inline, or no header at all, lets the type decide. |
X-Content-Type-Options | nosniff | Tells the browser to trust Content-Type and not guess from the content. Scripts and stylesheets with the wrong type are then blocked. |
The rules for nosniff are in the Fetch standard, and MDN has a shorter summary.
What we measured
We checked this with HeaderDial 0.3.0 in Chrome 159.0.8154.6 and Firefox 158.0.1 in November 2026. A local test server sent each file below, the browser opened its URL in a tab, and we recorded whether it was downloaded or shown and what type the page reported. Edge uses Chrome's engine, but we did not test it separately.
| Server sent | HeaderDial rule | Chrome 159 | Firefox 158 |
|---|---|---|---|
JSON as application/octet-stream | none | downloaded | downloaded |
JSON as application/octet-stream | Content-Type text/plain | shown as text | shown as text |
JSON as application/octet-stream | Content-Type application/json | shown as raw JSON | shown in the JSON viewer |
Text with Content-Disposition: attachment | Content-Type text/plain | still downloaded | still downloaded |
Text with Content-Disposition: attachment | Content-Disposition removed, or set to inline | shown | shown |
HTML as text/plain | Content-Type text/html | rendered as a page | rendered as a page |
HTML as text/plain | Content-Type removed | rendered as a page (the browser guessed HTML) | rendered as a page |
JSON as application/json | Content-Type application/octet-stream | downloaded | downloaded |
With no Content-Type at all, both browsers guessed HTML from the content. With no Content-Type and nosniff, both showed the same HTML as plain text.
Scripts and stylesheets with the wrong type
A common deployment bug is a JavaScript file served as text/plain together with nosniff, so the browser refuses to run it. Before you redeploy, you can check that the type is the only problem. A page loaded each script with a <script src> tag, and the script set a flag when it ran:
| Script served as | HeaderDial rule | Chrome 159 | Firefox 158 |
|---|---|---|---|
text/plain | none | ran | ran |
text/plain + nosniff | none | blocked | blocked |
text/plain + nosniff | Content-Type text/javascript | ran | ran |
text/plain + nosniff | X-Content-Type-Options removed | ran | still blocked |
text/javascript + nosniff | Content-Type text/plain | blocked | blocked |
text/plain | X-Content-Type-Options nosniff added | blocked | still ran |
So overriding Content-Type works in both browsers. Adding or removing X-Content-Type-Options changes script blocking in Chrome only. Firefox kept applying the header the server really sent, even though a fetch() of the same file reported the changed value. To fix a blocked script in both browsers, change the type, not nosniff.
Stylesheets served as text/plain were ignored in both browsers even without nosniff, because the test page was in standards mode. Overriding Content-Type to text/css made both browsers apply them.
Steps
- Click the HeaderDial icon. If the site-access banner appears, choose Allow on all sites or Only <current host>.
- Click + Response header. Type
Content-Type(it is in the suggestions) and the type you want, for exampletext/plain; charset=utf-8for a text or CSV file,application/jsonfor JSON, ortext/javascriptfor a script. Keep the operation on set. - If the file still downloads, the server probably sends
Content-Disposition: attachment. Click + Response header again, typeContent-Dispositionand choose remove. - Open Where it applies, click + Only on…, choose URL pattern and enter something that matches only the files you mean, such as
||files.example.com/exports/. A rule for the whole site would also change the type of every page, script and image on it. - Load the URL again. If you only want to change what a tab shows, tick main frame under the request types. Scripts and
fetch()calls then keep the server's type.
What JavaScript sees
In Chrome, response.headers.get('content-type') in a fetch() returned the overridden type. In Firefox it returned the type the server sent, although navigations, scripts and stylesheets used the override. Firefox did report other overridden response headers (X-Content-Type-Options, Content-Disposition, Cache-Control and more) to fetch(). If your own code branches on the type it reads from fetch(), test that part in Chrome. response.json() and response.text() read the body whatever the header says.
The curl equivalent
curl does not care about types, so it is the quickest way to see what the server really sends:
curl -sI https://files.example.com/exports/report.bin | grep -iE '^(content-type|content-disposition|x-content-type-options):'
# save the body regardless of type
curl -s https://files.example.com/exports/report.bin | head
Pitfalls
- Keep the filter narrow. A
Content-Typeoverride on a whole domain turns pages into text and stops scripts. Use a URL pattern for one file or folder. - Content-Disposition wins. Changing the type alone does not stop an
attachmentdownload in either browser. - Firefox and nosniff. Removing
X-Content-Type-Optionsdid not unblock a script in Firefox 158. Override the type instead. - Switch it off afterwards. Give the row an expiry such as 15 min, or press Alt+Shift+D to pause every profile.
Add to ChromeFirefox: coming soon