The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Apache2::MimeInfo - Content-Type header informed by shared-mime-info


Version 0.06


    PerlLoadModule Apache2::MimeInfo
    PerlOutputFilterHandler Apache2::MimeInfo


This module bolts File::MimeInfo::Magic and the shared-mime-info database to Apache 2.x. Its purpose is to clean up Content-Type headers on responses that come from potentially misconfigured or untrustworthy sources (e.g. a proxy).

Insert Apache2::MimeInfo as an output filter as described in the synopsis to perform content-based type checking against a more robust database than the one that comes along with file. The type asserted by the original content handler will be overridden by this filter unless the asserted type is a more specific instance of a more general detected type. For instance, Microsoft's .docx format is a ZIP file with special contents. Its MIME type is this:


The detector, however, will perceive application/zip, which is an ancestor type. If whatever content handler producing the document asserts the correct type, then this module will do nothing. If, however, it returns something like application/octet-stream, which is even more generic than application/zip, this module will replace the Content-Type header with application/zip. It will likewise replace the Content-Type header if it is missing altogether, or if it asserts a type that is inconsitent with the one which was detected.

If you aren't familiar with shared-mime-info, it's an XML database containing useful information about the mappings of, and relations between MIME types. This means that you can hack new type signatures into it, just as you can with file.


Dorian Taylor, <dorian at>


Please report any bugs or feature requests to bug-apache2-mimeinfo at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Apache2::MimeInfo

You can also look for information at:




Copyright 2013 Dorian Taylor.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at .

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.