Subject: | HTTP Status Line is Never Matched |
Please see the attached patch.
Additionally, the following lines are relevant to the discussion:
Line 139:
if (!$headers && $line =~ m{^HTTP/(1.[01]) \s+ (\d+)
(?: | \s+ .+)$ }x) {
Line 134:
my $headers = ${*$client}{'headers'} ||= {unparsed => '', parsed
=> ''};
Line 139 uses "!$headers" as a precondition for attempting to match the
current line against a regular expression representing the HTTP status
line, but line 134 initializes $headers to a boolean-true value (and it
is never reassigned), thus the match is never executed.
My guess is that the precondition was actually intended to be
"!$headers->{'parsed'}", i.e., if $line is the first line of input
(since previously read/parsed lines are appended to $headers->{'parsed'}).
Subject: | patch.txt |
*** Net/Server/HTTP.pm Mon Dec 17 18:10:45 2012
--- Net/Server/HTTP.pm Mon Dec 17 18:10:45 2012
***************
*** 134,144 ****
my $headers = ${*$client}{'headers'} ||= {unparsed => '', parsed => ''};
$headers->{'unparsed'} .= join('', @_);
while ($headers->{'unparsed'} =~ s/^(.*?)\015?\012//) {
my $line = $1;
! if (!$headers && $line =~ m{^HTTP/(1.[01]) \s+ (\d+) (?: | \s+ .+)$ }x) {
$headers->{'status'} = [];
$headers->{'parsed'} .= "$line\015\012";
$prop->{'request_info'}->{'http_version'} = $1;
$prop->{'request_info'}->{'response_status'} = $2;
}
--- 134,144 ----
my $headers = ${*$client}{'headers'} ||= {unparsed => '', parsed => ''};
$headers->{'unparsed'} .= join('', @_);
while ($headers->{'unparsed'} =~ s/^(.*?)\015?\012//) {
my $line = $1;
! if (!$headers->{parsed} && $line =~ m{^HTTP/(1.[01]) \s+ (\d+) (?: | \s+ .+)$ }x) {
$headers->{'status'} = [];
$headers->{'parsed'} .= "$line\015\012";
$prop->{'request_info'}->{'http_version'} = $1;
$prop->{'request_info'}->{'response_status'} = $2;
}