Skip Menu |

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

Report information
The Basics
Id: 78762
Status: resolved
Priority: 0/
Queue: Net-Server

People
Owner: Nobody in particular
Requestors: gkleen [...] praseodym.org
Cc:
AdminCc:

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



CC: "Paul T. Seamons" <paul [...] seamons.com>
Subject: Net::Server::HTTP - Sending of custom status does not work
Date: Fri, 3 Aug 2012 11:43:11 +0200
To: bug-Net-Server [...] rt.cpan.org
From: Gregor Kleen <gkleen [...] praseodym.org>
When using the package, as it is currently on cpan the following perl code answers querys with status '200 OK'. Expected behaviour would be to answer '404 Not found'. #!/usr/bin/perl # This is test.pl # The following command was used to inspect returned headers: # wget -q -O - -S --no-proxy 'localhost:8080' use strict; use warnings; package bugtest; use HTTP; use base qw(Net::Server::HTTP); sub process_http_request { my $self = shift; $self->send_status(404, 'Not found'); print "Content-type: text/plain\r\n\r\n404\r\n"; } __PACKAGE__->run( port => 8080 ); return 1; The problem seems to be the regular expression in line 93 not recognizing the Status lines produced by send_status(). This is easily fixed with the following patch. diff --git a/HTTP.pm b/HTTP.pm index b3511a7..32251a6 100644 --- a/HTTP.pm +++ b/HTTP.pm @@ -90,7 +90,7 @@ sub pre_bind { } ${*$client}{'headers_sent'} = 1; delete ${*$client}{'headers'}; - if ($headers =~ m{^HTTP/1.[01] \s+ \d+ (?: | \s+ .+)\r?\n}) { + if ($headers =~ m{^HTTP/1.[01] \s+ \d+ (?: | \s+ .+)\r?\n}x) { # looks like they are sending their own status } elsif ($headers =~ /^Status:\s+(\d+) (?:|\s+(.+?))\s*$/im) { The patch has also been attached to this mail.

Message body is not shown because sender requested not to inline it.

Download signature.asc
application/pgp-signature 836b

Message body not shown because it is not plain text.

So, perusing my history, it appears you are using a pre 2.000 version of Net::Server. This appears to have been fixed around May. If you continue to have issues with a more recent version of Net::Server, please let me know. Thank you for your report! Paul On Fri Aug 03 05:43:25 2012, gkleen@praseodym.org wrote: Show quoted text
> When using the package, as it is currently on cpan the following perl > code answers querys with status '200 OK'. Expected behaviour would be > to answer '404 Not found'. > > #!/usr/bin/perl > # This is test.pl > # The following command was used to inspect returned headers: > # wget -q -O - -S --no-proxy 'localhost:8080' > > use strict; > use warnings; > > package bugtest; > > use HTTP; > > use base qw(Net::Server::HTTP); > > sub process_http_request > { > my $self = shift; > > $self->send_status(404, 'Not found'); > print "Content-type: text/plain\r\n\r\n404\r\n"; > } > > __PACKAGE__->run( > port => 8080 > ); > > return 1; > > The problem seems to be the regular expression in line 93 not > recognizing the Status lines produced by send_status(). This is easily > fixed with the following patch. > > diff --git a/HTTP.pm b/HTTP.pm > index b3511a7..32251a6 100644 > --- a/HTTP.pm > +++ b/HTTP.pm > @@ -90,7 +90,7 @@ sub pre_bind { > } > ${*$client}{'headers_sent'} = 1; > delete ${*$client}{'headers'}; > - if ($headers =~ m{^HTTP/1.[01] \s+ \d+ (?: | \s+ .+)\r?\n}) { > + if ($headers =~ m{^HTTP/1.[01] \s+ \d+ (?: | \s+ .+)\r?\n}x) { > # looks like they are sending their own status > } > elsif ($headers =~ /^Status:\s+(\d+) (?:|\s+(.+?))\s*$/im) { > > The patch has also been attached to this mail.