Subject: | Allow HTTP status line without phrase part |
Perlbal::HTTPHeaders is quite strict about the status line in an HTTP
response:
# check for valid response line
return fail("Bogus response line") unless
$self->{responseLine} =~
m!^HTTP\/(\d+)\.(\d+)\s+(\d+)(?:\s+(.*))$!;
This means that the status line must contain both the response code
*and* the human-readable phrase. While the human-readable phrase
itself may be empty, the space between code and phrase is mandatory.
This seems to agree with the HTTP RFC
http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1
However it seems that it's possible that servers may incorrectly omit
the human-readable phrase in the response. For example, it is easy to
build such a response using CGI.pm
#!/usr/bin/perl
use CGI 'redirect';
print redirect(
-uri => 'http://www.perl.org',
-status => '301', # no phrase
#-status => '301 Moved', # this would be correct
);
__END__
Browsers like firefox can deal with this response. HTTP::Response also
does not care about the missing phrase, so all things using
LWP::UserAgent also work. Perlbal throws an error here, and blocks the
connection to the client until it times out. I wonder if Perlbal could
be also lax here and allow a missing phrase.
See also a related ticket in the CGI queue:
https://rt.cpan.org/Ticket/Display.html?id=76691
Regards,
Slaven