Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: RPKELLY [...] cpan.org
Cc:
AdminCc:

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



Subject: Net::Server::HTTP only ever returns status 200
Net::Server::HTTP will only return an HTTP status of 200 OK. (Alright, that's not true. If you try to return the header "HTTP/1.0 200 OK\n\n" the server will give an error saying it couldn't recognize any headers). The problem is with the regular expression used to match the status line. It attempts to match a literal space, followed by one or more spaces, followed by a number followed by at least two literal spaces or three literal spaces and a message. The attached patch resolves the issue.
Subject: HTTP.pm.patch
93c93 < if ($headers =~ m{^HTTP/1.[01] \s+ \d+ (?: | \s+ .+)\r?\n}) { --- > if ($headers =~ m{^HTTP/1.[01]\s\d+ (.+)?\r?\n}) {
On Sun Aug 01 22:57:59 2010, RPKELLY wrote: Show quoted text
> The problem is with the regular expression used to match the status > line. It attempts to match a literal space, followed by one or more > spaces, followed by a number followed by at least two literal spaces
or Show quoted text
> three literal spaces and a message. The attached patch resolves the
issue. I think the regexp is missing a "/x" flag: --- lib/Net/Server/HTTP.pm.old 2012-01-16 15:49:17.000000000 +0000 +++ lib/Net/Server/HTTP.pm 2012-01-16 15:49:59.000000000 +0000 @@ -90,7 +90,7 @@ } ${*$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) {
Thank you for the glaring bugfix. The code is updated as of the just released version 2.000 On Mon Jan 16 11:08:30 2012, DIOCLES wrote: Show quoted text
> On Sun Aug 01 22:57:59 2010, RPKELLY wrote:
> > The problem is with the regular expression used to match the status > > line. It attempts to match a literal space, followed by one or more > > spaces, followed by a number followed by at least two literal spaces
> or
> > three literal spaces and a message. The attached patch resolves the
> issue. > > I think the regexp is missing a "/x" flag: > > --- lib/Net/Server/HTTP.pm.old 2012-01-16 15:49:17.000000000 +0000 > +++ lib/Net/Server/HTTP.pm 2012-01-16 15:49:59.000000000 +0000 > @@ -90,7 +90,7 @@ > } > ${*$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) {