Content-Type Fixer Extension for Firefox (AMO Listing)

Content-Type Fixer (CTF) was created to work around servers providing inconsistent and unhelpful Content-Type headers for files, forcing the frequent/repeated appearance of the Download dialog when Firefox already had instructions for handling the files automatically. Firefox 98 has changed the downloading workflow so that Firefox skips the Download dialog and saves the file automatically (or asks you where to save the file). This extension cannot bring back showing the Download dialog for unknown content types, but it can help you take control of handling of known content types.

General Function

Once you click its Zzzz toolbar button to start listening to requests, CTF checks two kinds of requests: (A) Top level requests, which covers download and the URLs you see in the address bar, and (B) Framed page requests. This extension does not check embedded content requests, and therefore, it should not affect performance significantly. Still, if you don't need it, you can turn it off.

File extension is everything. CTF changes the Content-Type based on the file extension (such as .docx or .zip). Sometimes this file extension is obvious from the link you clicked, and sometimes it is provided by the server in a Content-Disposition header. If CTF cannot determine the extension of the file, it cannot change the Content-Type.

Built-in Content Type Overrides

CTF will automatically correct the Content-Type for common file extensions such as .pdf, .docx, and .zip. The extension also has some built-in types that are not enabled at the time of installation, such as image and media files. You can enable these if you have difficulty viewing images and videos with those file extensions in a tab in Firefox (i.e., in cases of forced downloading).

Roll Your Own Content Type Overrides

CTF allows adding new Content-Type overrides to suit your needs. You set them up through the Log page, which shows what a server is sending to Firefox and what CTF has been doing. After you add a custom override, it will appear in the overrides list along with the built-in overrides.

As an example, let's look at adding a new override for OFX files. To simulate the problem, we'll first download an example file: empty.ofx. Firefox 98+ will automatically save the file. Because the server didn't provide a specific content-type for this file, the "Always Open Similar Files" item is missing from the right-click context menu for the file. This means the main feature for managing how Firefox opens .ofx files can't be used with this server. 😔

Open the CTF menu and select "Add/Edit Content Types (View Log)". A new tab should open showing the latest few minutes of downloads. The log will show what the server is sending – usually the problem is "application/octet-stream", which is the same type sent for executable files and is not application specific. You'll notice an "Add" button below the text. You'll click that button to open a form.

The form allows entering your own preferred content-type, but the fictitious one works just fine for most purposes, so you can simply click the "Save Content-Type" button. You are done here.

Return to your main page and trigger the download again. Firefox will again save the file automatically, but you should now be able to click "Always Open Similar Files" for the new download. Choosing that item opens the file and also adds a new entry to the Applications list on the Settings page. As described in the help article Content types and download actions in Firefox, you then can select another application, or "Always ask" for the classic Download experience.

Content-Disposition

Servers use a second method to force downloading, which is to set the Content-Disposition to "attachment". You can use selections on the CTF menu to override the Content-Disposition header for all downloads. Currently there are three options:

When you select "Follow my settings (inline)", CTF removes attachment disposition from all downloads. From time to time, you might want to use "Force downloading (attachment)." Please do not uncheck the box for text/html unless a server is mistakenly identifying a download as a web page and make sure to switch that back because otherwise you won't be able to read any pages in Firefox.

Permission Design

CTF needs to intercept requests to a wide variety of servers, so it seems impractical to have users grant permission individually. Hopefully in the future Firefox will make that easier so you don't need to pre-approve access to all sites. Until then, you just have to trust me when I say that I have no interested in your browsing.

Source Code

Firefox extensions are .xpi files, which are .zip archives. So you can download extensions and open them in your favorite unarchiving program to see the source code. But it may be easier to read on Github: https://github.com/jscher2000/Content-Type-Fixer-extension.