You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Michele Gherlone <mi...@liceoberchet.it> on 2005/07/20 01:33:31 UTC
Strange error in log when trying to implement PerlTypeHandler
Hi all!
I was trying to bypass mod_mime for certain mime type, and
I wrote this small handler:
--------------------------------
package Apache::MIMEMagic;
$Apache::MIMEMagic::VERSION='0.10';
use Apache2::Const -compile => qw(OK DECLINED);
use File::MMagic;
use strict;
sub handler {
my $r = shift;
my
$ct=File::MMagic->new->checktype_filename($r->filename);
$r->handler('default-handler');
$r->content_type($ct);
return Apache2::Const::OK;
}
1;
---------------------------------
Since I was running it for a dir under my docroot, i had
to set Apache's default-handler. All went fine, docs were
correctly served, but in my logs for every served
document, this error line appeared:
`Invalid type 'the' at line 1`.
I really wish I could know where this error comes from.
Perhaps from mod_mime itself, or...?
TIA
Mike
Re: Strange error in log when trying to implement PerlTypeHandler
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>> I really wish I could know where this error comes from. Perhaps from
>> mod_mime itself, or...?
>
>
> grep the apache sources for 'Invalid type' string?
I did last night - that error is coming from File::MMagic.
--Geoff
Re: Strange error in log when trying to implement
PerlTypeHandler
Posted by Michele Gherlone <mi...@liceoberchet.it>.
On Wed, 20 Jul 2005 12:05:34 +0200
Stas Bekman <st...@stason.org> wrote:
>*This message was transferred with a trial version of
>CommuniGate(tm) Pro*
>Michele Gherlone wrote:
>> Hi all!
>> I was trying to bypass mod_mime for certain mime type,
>>and I wrote this
>> small handler:
>> --------------------------------
>> package Apache::MIMEMagic;
>> $Apache::MIMEMagic::VERSION='0.10';
>> use Apache2::Const -compile => qw(OK DECLINED);
>> use File::MMagic;
>> use strict; sub handler { my $r = shift;
>> my
>>$ct=File::MMagic->new->checktype_filename($r->filename);
>> $r->handler('default-handler');
>> $r->content_type($ct);
>> return Apache2::Const::OK;
>> }
>> 1;
>> ---------------------------------
>> Since I was running it for a dir under my docroot, i had
>>to set Apache's
>> default-handler. All went fine, docs were correctly
>>served, but in my
>> logs for every served document, this error line
>>appeared:
>> `Invalid type 'the' at line 1`.
>
>What's the value of $ct?
-----------------------------------------------
package Apache::MIMEMagic;
$Apache::MIMEMagic::VERSION='0.10';
use Apache2::Const -compile => qw(OK DECLINED);
use File::MMagic;
use strict;
sub handler {
my $r = shift;
my
$ct=File::MMagic->new->checktype_filename($r->filename);
print STDERR "Filename passed to File::MMagic:
",$r->filename,"\n";
$r->handler('default-handler');
print STDERR "After setting the default handler\n";
$r->content_type($ct);
print STDERR "After setting the content type: $ct, the
content_type is: ",$r->content_type,"\n";
return Apache2::Const::OK;
}
1;
With this `print STDERR` debug lines attached, i could
realize that the `Invalid type 'the'` error comes out
sometimes once sometimes twice per request. $ct is always
set to a correct mime/type when it gets printed. Since the
error comes from File::MMagic itself (thx to Geoff), I
wonder when does the handler get invoked and how many
times per request, untill it can set the request_content.
Maybe it gets called when $r->filename is undef or eq '',
so causing File::MMagic to fail. I'll try to add an if
clause.
Thx for your reply.
Mike.
----------------------------------------------
>> I really wish I could know where this error comes from.
>>Perhaps from
>> mod_mime itself, or...?
>
>grep the apache sources for 'Invalid type' string?
>
>--
>__________________________________________________________________
>Stas Bekman JAm_pH ------> Just Another
>mod_perl Hacker
>http://stason.org/ mod_perl Guide --->
>http://perl.apache.org
>mailto:stas@stason.org http://use.perl.org
>http://apacheweek.com
>http://modperlbook.org http://apache.org
> http://ticketmaster.com
Re: Strange error in log when trying to implement PerlTypeHandler
Posted by Stas Bekman <st...@stason.org>.
Michele Gherlone wrote:
> Hi all!
> I was trying to bypass mod_mime for certain mime type, and I wrote this
> small handler:
> --------------------------------
> package Apache::MIMEMagic;
> $Apache::MIMEMagic::VERSION='0.10';
> use Apache2::Const -compile => qw(OK DECLINED);
> use File::MMagic;
> use strict; sub handler { my $r = shift;
> my $ct=File::MMagic->new->checktype_filename($r->filename);
> $r->handler('default-handler'); $r->content_type($ct);
> return Apache2::Const::OK;
> }
> 1;
> ---------------------------------
> Since I was running it for a dir under my docroot, i had to set Apache's
> default-handler. All went fine, docs were correctly served, but in my
> logs for every served document, this error line appeared:
> `Invalid type 'the' at line 1`.
What's the value of $ct?
> I really wish I could know where this error comes from. Perhaps from
> mod_mime itself, or...?
grep the apache sources for 'Invalid type' string?
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com