jscher2000 / Content-Type-Fixer-extension

Firefox extension to override dumb Content-Type headers with correct values
Mozilla Public License 2.0
23 stars 2 forks source link

Could not fix content-type for PDF on shinygarage.pl site #14

Open SylwesterZarebski opened 2 years ago

SylwesterZarebski commented 2 years ago

Hi, i'm trying to force opening PDF in browser, but below site is forcing me to download it: https://shinygarage.pl/plyn-do-mycia-szyb-perfect-glass-cleaner Scroll to Pliki do pobrania and then try to download Karta charakterystyki (MSDS) - PL (link works here too). Server send content-type: application/force-download, and extension do not show any log for it.

How to avoid forcing download?

PS. It looks like somehow file handlers.json have entry of application/force-download which force download even for PDF:

"application/force-download":{"action":0,"ask":false,"extensions":["rar"]}

After removing this entry, opening file in browser works even without this extension.

PPS. Temporarily i've changed above to

"application/force-download":{"action":3,"ask":true,"extensions":["rar","pdf"]}

Is handlers.json detection takes place before addon?

jscher2000 commented 2 years ago

Sorry for the delayed reply. I'm on Firefox 100 now. A lot of things about downloading changed in Firefox 98, so your experience might be different now as well.

The PDF opened in the same tab for me.

When I call up "Add/Edit Content Types (View Log)" from the menu, my log shows that the Content-Type was switched:

C-T: Updated CT header from "application/force-download" to "application/pdf"

I'm not sure what went wrong on yours.

SylwesterZarebski commented 2 years ago

I'm using the same version now, but no change in behaviour. In log i have:

8.05.2022, 21:26:14 | https://shinygarage.pl/plyn-do-mycia-szyb-perfect-glass-cleaner (main_frame) |   | C-T: N/A - file extension unavailable

Current options: obraz

Also override is set: obraz

jscher2000 commented 2 years ago

Hmm, when you click the link to the PDF file, the PDF file itself then should appear in the log. If it doesn't, I wonder whether it is being retrieved from the cache somehow?

SylwesterZarebski commented 2 years ago

No log on click link to PDF. Entry shows up when refreshing page - only on full refresh, cached one do not make entry.

SylwesterZarebski commented 2 years ago

On right click and Save destination as... there is log entry:

8.05.2022, 21:45:29 | https://shinygarage.pl/pl/p/file/e02f7c958a60b36e3e850d0a30a49aba/___Shiny-Garage-Perfect-Glass-Cleaner-sds-PL-878.pdf (other) | pdf |
C-T: Updated CT header from "application/force-download" to "application/pdf"
C-D: Changed from attachment to inline
C-D: Changed from  to inline
SylwesterZarebski commented 2 years ago

In developer settings i have disabled HTTP cache and in Network tab it looks like response is not cached (non parsed response headers):

HTTP/1.1 200 OK
date: Sun, 08 May 2022 19:52:19 GMT
content-type: application/force-download
content-length: 735747
last-modified: Thu, 24 Mar 2022 09:28:44 GMT
expires: 0
cache-control: must-revalidate, post-check=0, pre-check=0, private
content-disposition: attachment; filename="___Shiny-Garage-Perfect-Glass-Cleaner-sds-PL-878.pdf";
etag: "623c39cc-b3a03"
x-xss-protection: 1
x-powered-by: DCSaaS
accept-ranges: bytes
server: DCSaaS/httpd
x-content-type-options: nosniff
X-Firefox-Spdy: h2

Cleared all cookies and other data, no change. Maybe some other addon block working, trying to disable uBlock and uMatrix, but no change also.

jscher2000 commented 2 years ago

I don't know why the add-on is not intercepting the regular request, only the right-click > Save Link As... request.

It's also difficult to think of what type of extension could interfere. I don't think there are very many related to content-type or content-disposition.

SylwesterZarebski commented 2 years ago

Is there anything i could do to help?