Subject: | Net::Server::HTTP cannot invoke CGI.pm; missing FILENO from Net::Server::TiedHandle on cygwin |
running perl 5.10 under cygwin on Windows:
this script is from the Net::Server::HTTP pod (Except for change in
port, and pushing to a single threaded server):
use base qw(Net::Server::HTTP);
__PACKAGE__->run(port=>4444, server_type=>'Single');
sub process_http_request {
my $self = shift;
print "Content-type: text/html\n\n";
print "<form method=post action=/bam><input type=text
name=foo><input type=submit></form>\n";
if (require Data::Dumper) {
local $Data::Dumper::Sortkeys = 1;
my $form = {};
if (require CGI) { my $q = CGI->new; $form->{$_} = $q->param($_)
for $q->param; }
print "<pre>".Data::Dumper->Dump([\%ENV, $form], ['*ENV',
'form'])."</pre>";
}
}
when run (with CGI 3.50) and a request is received, this error occurs:
Can't locate object method "FILENO" via package
"Net::Server::TiedHandle" at /usr/lib/perl5/5.10/CGI.pm line 823.
Compilation failed in require at server.pl line 13.
my short term workaround is to add a dummy FILENO method to TiedHandle:
package Net::Server::TiedHandle;
sub TIEHANDLE { my $pkg = shift; return bless [@_], $pkg }
sub READLINE { my $s = shift; $s->[1] ? $s->[1]->($s->[0], 'getline',
@_) : $s->[0]->getline }
sub SAY { my $s = shift; $s->[1] ? $s->[1]->($s->[0], 'say',
@_) : $s->[0]->say(@_) }
sub PRINT { my $s = shift; $s->[1] ? $s->[1]->($s->[0], 'print',
@_) : $s->[0]->print(@_) }
sub PRINTF { my $s = shift; $s->[1] ? $s->[1]->($s->[0], 'printf',
@_) : $s->[0]->printf(@_) }
sub READ { my $s = shift; $s->[1] ? $s->[1]->($s->[0], 'read',
@_) : $s->[0]->read(@_) }
sub WRITE { my $s = shift; $s->[1] ? $s->[1]->($s->[0], 'write',
@_) : $s->[0]->write(@_) }
sub SYSREAD { my $s = shift; $s->[1] ? $s->[1]->($s->[0], 'sysread',
@_) : $s->[0]->sysread(@_) }
sub SYSWRITE { my $s = shift; $s->[1] ? $s->[1]->($s->[0], 'syswrite',
@_) : $s->[0]->syswrite(@_) }
sub FILENO { return undef; }
1;
problem does NOT occur on Linux with Perl 5.8.8, Net::Server 0.99, CGI
3.15 or 3.50, so it appears to be a 5.10 or cygwin/windows issue.