Skip Menu |

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

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

People
Owner: sjq-perl [...] jadevine.org.uk
Requestors: MARKSTOS [...] cpan.org
Cc:
AdminCc:

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



Hello, the attached patch fixes two bugs triggered when empty content is returned: 1. two warnings showed up on STDERR (examples below) 2. I was oddly prompted to download a file of type "BIN". That was because the MIME-type had been set to "application/octet-stream". (That's how File::MMagic says "I don't know" ). Thanks! Mark Use of uninitialized value in length at lib/HTTP/Server/Simple/Static.pm line 46. Use of uninitialized value in print at lib/HTTP/Server/Simple/Static.pm line 47.
Subject: simple_static_no_content.patch
--- /usr/local/share/perl/5.8.8/HTTP/Server/Simple/Static.pm 2006-11-06 04:43:00.000000000 -0500 +++ lib/HTTP/Server/Simple/Static.pm 2007-07-21 14:00:33.000000000 -0400 @@ -37,8 +37,16 @@ $fh->close; my $mimeobj = $mime->mimeTypeOf($path); - my $mime = ($mimeobj ? $mimeobj->type : - $magic->checktype_contents($content)); + my $mime = $mimeobj->type if $mimeobj; + + if (defined $content) { + $mime ||= $magic->checktype_contents($content); + } + # No content defined? Use some sane defaults + else { + $content = ''; + $mime = 'text/plain'; + } use bytes; # Content-Length in bytes, not characters print "HTTP/1.1 200 OK\015\012";
From: sjq-perl [...] jadevine.org.uk
On Sat Jul 21 14:13:36 2007, MARKSTOS wrote: Show quoted text
> Hello, the attached patch fixes two bugs triggered when empty content is > returned: > > 1. two warnings showed up on STDERR (examples below) > 2. I was oddly prompted to download a file of type "BIN". That was > because the MIME-type had been set to "application/octet-stream". > (That's how File::MMagic says "I don't know" ). >
Thanks for the bug report, I've uploaded version 0.06 which fixes the problem. Stephen