<div dir="ltr"><div>Hi,</div><div><br></div><div>In AnyEvent::HTTP 2.25 (and Perl 5.22), I encountered a response parsing issue.</div><div><br></div><div>The problem comes from a response without a Reason (valid HTTP):<br></div><div>From curl:<br></div><div>< HTTP/1.1 400 <br>< Content-Length: 0<br>< Date: Tue, 23 Jan 2024 14:49:24 GMT<br>< Connection: close<br>< </div><div><br></div><div>Hex of the 2 first lines:</div><div>[48][54][54][50][2f][31][2e][31][20][34][30][30][20][0d][0a]</div><div>[43][6f][6e][74][65][6e][74][2d][4c][65][6e][67][74][68][3a][20][30][0d][0a]</div><div>(note: AnyEvent::HTTP removes all 0d before the following regex)<br></div><div><br></div><div>In the pattern in AnyEvent::HTTP, parsing the first response line:<br></div><div>  /^HTTP\/0*([0-9\.]+) \s+ ([0-9]{3}) (?: \s+ ([^\012]*) )? \012/gxci</div><div>the second "\s+" matches the \012 (along with the preceding space), so that "Content-Length: 0" becomes the parsed Reason ($3).</div>Replacing it with "[ \f\t\cK]+" (\s without \r\n) fixes the issue, for example.<div><br></div><div>  /^HTTP\/0*([0-9\.]+) \s+ ([0-9]{3}) (?: [ \f\t\cK]+ ([^\012]*) )? \012/gxci</div><div><br></div><div>Then, "Reason" becomes an empty string as expected.<br></div><div><br></div><div>Thanks,<br></div><div><br></div></div>