Subject: | Misplaced local(*F) in HTTP::Daemon::send_file() |
If you pass a filename to HTTP::Daemon::send_file() (instead of going through HTTP::Daemon::send_file_response(), which passes a reference to a typeglob), *F is localized improperly, and becomes unlocalized prematurely, causing sysread() to fail. The result is that no bytes are sent back down the socket.
The workaround (attached) is to move "local(*F)" up a few lines.
I'm running ActiveState 5.6.1, libwww-perl 5.51 (HTTP::Daemon.pm v 1.24, though that area of code is unchanged in 1.25).
*** Daemon.pm Fri Oct 18 02:42:01 2002
--- Daemon.pm.fix Fri Oct 18 02:42:52 2002
***************
*** 768,776 ****
sub send_file
{
my($self, $file) = @_;
my $opened = 0;
if (!ref($file)) {
- local(*F);
open(F, $file) || return undef;
binmode(F);
$file = \*F;
--- 768,776 ----
sub send_file
{
my($self, $file) = @_;
+ local(*F);
my $opened = 0;
if (!ref($file)) {
open(F, $file) || return undef;
binmode(F);
$file = \*F;