gz/gzip incorrect mime type

gz/gzip incorrect mime type

by D M -
Number of replies: 6

Hello,

We have a SCORM course that contains pre-compressed .js.gz files. In Moodle 2.9, these are being served by "pluginfile.php", but the "Content-Type" header being given to the browser is "application/g-zip". Where is this value coming from?

I tried editing /lib/classes/filetypes.php and purging all caches, but it makes absolutely no difference. Moodle still sends "application/g-zip" to the browser, and I can't find any other instance of this value in the PHP code. Is it stored in the database by any chance? The content-type header should be "application/x-gzip".

Any help would be greatly appreciated, thank you.

DM

Average of ratings: -
In reply to D M

Re: gz/gzip incorrect mime type

by Matteo Scaramuccia -
In reply to Matteo Scaramuccia

Re: gz/gzip incorrect mime type

by D M -

I did try the built-in file types admin page, and this seems to have no effect on the .js.gz files. I'm inspecting through Chrome, and the content-type header is always "application/g-zip" no matter what changes I make.

In reply to D M

Re: gz/gzip incorrect mime type

by Dimitar Ivanov -

This seems to be defined here:

https://github.com/moodle/moodle/blob/MOODLE_29_STABLE/lib/classes/filetypes.php#L104


Get yourself some IDE like Netbeans, that way it will be much easier to "follow" the code.

You can also use github's search function:

https://github.com/moodle/moodle/search?utf8=%E2%9C%93&q=g-zip





In reply to Dimitar Ivanov

Re: gz/gzip incorrect mime type

by D M -

That's what I thought too, but editing /lib/classes/filetypes.php has no effect on the "content-type" header returned by Moodle. It's always "application/g-zip" no matter what changes I make to filetypes.php, or through the File Types admin page.

In reply to D M

Re: gz/gzip incorrect mime type

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers

The file type is stored at the time the file is saved to Moodle. So if you change the mime type references, only new files will be affected. You should also purge caches if you edit that file, before adding a new file. 

In reply to Eric Merrill

Re: gz/gzip incorrect mime type

by D M -

This is the answer I was looking for, thank you.

However, in the end Moodle still doesn't know how to properly serve pre-compressed .js.gz files (and likely others). I ended up having to add extra conditions to /lib/filelib.php in order to accommodate. The "content-type" header was wrong, and the "content-encoding" header was missing completely.

Anyway, our SCORM course works now. Thanks for all the help!

Average of ratings: Useful (1)