p5-http-parser-xs
p5-http-parser-xs copied to clipboard
Parser does not like a Status-Line with no Reason-Phrase and no ending space
For HTTP/1.1, the Status-Line ( https://datatracker.ietf.org/doc/html/rfc2616#section-6.1 ) does not need a Reason-Phrase
Definitions:
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
Reason-Phrase = *<TEXT, excluding CR, LF>
However, the spec does seem to require a SP after Status-Code, even if there isn't a Reason-Phrase, but most clients can handle this without trouble.
HTTP::Parser::XS does not like it though:
use strict;
use warnings;
use Data::Dumper;
use HTTP::Parser::XS qw(parse_http_response HEADERS_AS_ARRAYREF);
my $ret = parse_http_response(
"HTTP/1.1 200 \r\nWhat: The\r\n\r\nHi",
HEADERS_AS_ARRAYREF
);
warn Dumper $ret;
$ret = parse_http_response(
"HTTP/1.1 200\r\nWhat: The\r\n\r\nHi",
HEADERS_AS_ARRAYREF
);
warn Dumper $ret;
$VAR1 = [
'what',
'The'
];
$VAR1 = -1;
Can we make the parsing more lax here?