HeaderDial › Guides

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:

HeaderExampleEffect on a page load
Content-Typeapplication/octet-streamA type the browser cannot display, so it downloads the file. text/plain, text/html, application/json and images are displayed.
Content-Dispositionattachment; filename="report.csv"Downloads the file whatever its type. inline, or no header at all, lets the type decide.
X-Content-Type-OptionsnosniffTells 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 sentHeaderDial ruleChrome 159Firefox 158
JSON as application/octet-streamnonedownloadeddownloaded
JSON as application/octet-streamContent-Type text/plainshown as textshown as text
JSON as application/octet-streamContent-Type application/jsonshown as raw JSONshown in the JSON viewer
Text with Content-Disposition: attachmentContent-Type text/plainstill downloadedstill downloaded
Text with Content-Disposition: attachmentContent-Disposition removed, or set to inlineshownshown
HTML as text/plainContent-Type text/htmlrendered as a pagerendered as a page
HTML as text/plainContent-Type removedrendered as a page (the browser guessed HTML)rendered as a page
JSON as application/jsonContent-Type application/octet-streamdownloadeddownloaded

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 asHeaderDial ruleChrome 159Firefox 158
text/plainnoneranran
text/plain + nosniffnoneblockedblocked
text/plain + nosniffContent-Type text/javascriptranran
text/plain + nosniffX-Content-Type-Options removedranstill blocked
text/javascript + nosniffContent-Type text/plainblockedblocked
text/plainX-Content-Type-Options nosniff addedblockedstill 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

  1. Click the HeaderDial icon. If the site-access banner appears, choose Allow on all sites or Only <current host>.
  2. Click + Response header. Type Content-Type (it is in the suggestions) and the type you want, for example text/plain; charset=utf-8 for a text or CSV file, application/json for JSON, or text/javascript for a script. Keep the operation on set.
  3. If the file still downloads, the server probably sends Content-Disposition: attachment. Click + Response header again, type Content-Disposition and choose remove.
  4. 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.
  5. 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

This changes what your browser does, not what the server sends. Fix the type on the server too: other visitors still get the download or the blocked script.

Add to ChromeFirefox: coming soon