Through my MP2 handler, I need to be able to set Content-Type based on
the extension of any file that I'm reading from disk and then writing
to the client. I'd like to somehow (programmatically) map from file
extension to MIME type, and it seems like Apache's mime.types file is
a good place to do this. Unfortunately it doesn't look like there's
an API for this. Am I wrong? Any other ideas aside from reading (and
potentially caching) the mime.types file directly?
http://search.cpan.org/dist/File-MMagic-XS/
So is this module something that should be implemented in a
PerlTypeHandler [1]? No one had their hands up in Geoff's testing talks
when he asked about who has written a PerlTypeHandler from the two I've
been to, but iirc he was referring to mp1 when he asked that. From
looking at the HTTP Handlers section of the docs, PerlTypeHandler runs
before the PerlResponseHandler, so it seems that the type could be
dependent on the response.
[1]
http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlTypeHandler