Skip Menu |

This queue is for tickets about the Net-Async-HTTP-Server CPAN distribution.

Report information
The Basics
Id: 105470
Status: resolved
Priority: 0/
Queue: Net-Async-HTTP-Server

People
Owner: Nobody in particular
Requestors: chris [...] lokku.com
Cc:
AdminCc:

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



Subject: Can't call method "path" on an undefined value at .../perl-5.18.4/lib/site_perl/5.18.4/Net/Async/HTTP/Server/Protocol.pm line 35.
Date: Wed, 24 Jun 2015 13:55:43 +0100
To: bug-Net-Async-HTTP-Server [...] rt.cpan.org
From: Chris Hughes <chris [...] lokku.com>
Hi, Use the script from this blog post: http://leonerds-code.blogspot.co.uk/2013/03/netasynchttpserver.html telnet localhost 8080 and hit return 3 times (ie just send a blank 'request'): Can't call method "path" on an undefined value at .../perl-5.18.4/lib/site_perl/5.18.4/Net/Async/HTTP/Server/Protocol.pm line 35. Net::Async::HTTP::Server::Protocol::on_read('Net::Async::HTTP::Server::Protocol=HASH(0x20dcd40)', 'SCALAR(0x20dd160)', '') called at .../perl-5.18.4/lib/site_perl/5.18.4/IO/Async/Notifier.pm line 777 IO::Async::Notifier::invoke_event('Net::Async::HTTP::Server::Protocol=HASH(0x20dcd40)', 'on_read', 'SCALAR(0x20dd160)', '') called at .../perl-5.18.4/lib/site_perl/5.18.4/IO/Async/Stream.pm line 920 IO::Async::Stream::_flush_one_read('Net::Async::HTTP::Server::Protocol=HASH(0x20dcd40)', '') called at .../perl-5.18.4/lib/site_perl/5.18.4/IO/Async/Stream.pm line 1000 IO::Async::Stream::_do_read('Net::Async::HTTP::Server::Protocol=HASH(0x20dcd40)') called at .../perl-5.18.4/lib/site_perl/5.18.4/IO/Async/Stream.pm line 954 IO::Async::Stream::on_read_ready(undef) called at .../perl-5.18.4/lib/site_perl/5.18.4/IO/Async/Loop/Poll.pm line 168 IO::Async::Loop::Poll::post_poll('IO::Async::Loop::Poll=HASH(0x20dc8d8)') called at .../perl-5.18.4/lib/site_perl/5.18.4/IO/Async/Loop/Poll.pm line 264 IO::Async::Loop::Poll::loop_once('IO::Async::Loop::Poll=HASH(0x20dc8d8)', undef) called at .../perl-5.18.4/lib/site_perl/5.18.4/IO/Async/Loop.pm line 512 IO::Async::Loop::run('IO::Async::Loop::Poll=HASH(0x20dc8d8)') called at httpserver.pl line 28 The code doesn't check the request is reasonable: Protocol.pm: 22 sub on_read 23 { 24 my $self = shift; 25 my ( $buffref, $eof ) = @_; 26 27 return 0 if $eof; 28 29 return 0 unless $$buffref =~ s/^(.*?$CRLF$CRLF)//s; 30 my $header = $1; 31 32 my $request = HTTP::Request->parse( $header ); 33 my $request_body_len = $request->content_length || 0; 34 35 $self->debug_printf( "REQUEST %s %s", $request->method, *$request->uri->path *); 36 37 return sub { 38 my ( undef, $buffref, $eof ) = @_; 39 40 return 0 unless length($$buffref) >= $request_body_len; 41 42 $request->add_content( substr( $$buffref, 0, $request_body_len, "" ) ); 43 44 push @{ $self->{requests} }, my $req = Net::Async::HTTP::Server::Request->new( $self, $request ); 45 $self->parent->_received_request( $req ); 46 47 return undef; thanks, Chris
Fixed -- Paul Evans
Subject: rt105470.patch
=== modified file 'lib/Net/Async/HTTP/Server/Protocol.pm' --- lib/Net/Async/HTTP/Server/Protocol.pm 2015-07-08 18:09:49 +0000 +++ lib/Net/Async/HTTP/Server/Protocol.pm 2015-09-09 14:40:02 +0000 @@ -29,6 +29,11 @@ my $header = $1; my $request = HTTP::Request->parse( $header ); + unless( $request and defined $request->protocol and $request->protocol =~ m/^HTTP/ ) { + $self->close_now; + return 0; + } + my $request_body_len = $request->content_length || 0; $self->debug_printf( "REQUEST %s %s", $request->method, $request->uri->path );
Released (ages ago) -- Paul Evans