Skip Menu |

This queue is for tickets about the HTTP-Server-Simple-Static CPAN distribution.

Report information
The Basics
Id: 11416
Status: resolved
Priority: 0/
Queue: HTTP-Server-Simple-Static

People
Owner: Nobody in particular
Requestors: corion [...] corion.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Date: Tue, 08 Feb 2005 09:07:57 +0100
From: Max Maischein <corion [...] corion.net>
To: bug-HTTP-Server-Simple-Static [...] rt.cpan.org
Subject: serve_static() determines MIME type for the wrong thing
In HTTP::Server::Simple v0.01, the subroutine serve_static() is a bit wrong: sub serve_static { my ($self,$cgi,$base) = @_; my $path = $cgi->url( -absolute => 1, -path_info => 1 ); # Sanitize the path and try it. $path = $base.canonpath(uri_unescape($path)); if (-e $path and open FILE, $path) { local $/; my $content=<FILE>; my $mimeobj= $mime->mimeTypeOf($base); my $mime = ($mimeobj ? $mimeobj->type : $magic->checktype_contents($content)); print "HTTP/1.1 200 OK\n"; print "Content-type: ", $mime, "\n"; print "Content-length: ", length($content), "\n\n"; print $content; return 1 ; } return 0; } The line my $mimeobj= $mime->mimeTypeOf($base); is wrong. It gets the mime type of the base directory, and not of a served file. It should be my $mimeobj= $mime->mimeTypeOf($path); to actually get the mime type of the served object. Also, the server should (optionally) warn if it doesn't find a file, for easier local diagnosis :-) Thanks for writing this useful extension to HTTP::Server::Simple! Have fun, -max
Date: Tue, 08 Feb 2005 12:20:34 +0100
From: Marcus Ramberg <marcus [...] thefeed.no>
To: bug-HTTP-Server-Simple-Static [...] rt.cpan.org
Subject: Re: [cpan #11416] serve_static() determines MIME type for the wrong thing
RT-Send-Cc:
Max Maischein via RT skrev: Show quoted text
>In HTTP::Server::Simple v0.01, the subroutine serve_static() is a bit wrong: > >
Hey Max, Thanks for the Bug Report, I'll apply this this evening and release new version. Marcus