[Dancer-users] mime types
ambs
ambs+dancer at perl-hackers.net
Thu Feb 10 16:45:00 CET 2011
Hi,
On 10/02/2011 15:37, Oleg A. Mamontov wrote:
> After some debugging i found that MIME::Types (used in Dancer::MIME)
> read and parse mime types from it DATA handle.
> This handle is opening by Perl during module load procedure. But subsequent
> reads occured in&MIME::Types::init (which called from constructor).
Yes, that's my code. The problem with DATA is that if I request a rewind
on the file handle I get to the beginning of the Perl file. Also, that
would need to be fixed directly on the module that, probably, we do not
have access.
> 1. Remove MIME::Types from Dancer::MIME completely :)
This would lead to the need of replicating some of the code. Although
Dancer folks try to minimize the number of dependencies I try to
convince them to minimize the amount of proprietary code that is already
available on other modules :)
>
> 2. Explicitly call&MIME::Types::init early (before fork):
>
> package Dancer::MIME;
> use strict;
> use warnings;
> use base 'Dancer::Object::Singleton';
> use MIME::Types;
>
> MIME::Types->init;
>
> 3. Use MIME::Types later (in&Dancer::MIME::init):
>
> sub init {
> my ($class, $instance) = @_;
> eval "use MIME::Types";
> $instance->mime_type(MIME::Types->new(only_complete => 1));
> $instance->aliases({});
> }
Did you try both solutions? Personally I prefer the first one and I'm
happy to prepare the patch on git.
Cheers
ambs
More information about the Dancer-users
mailing list