facebook/hhvm — pull request #2874 by atdt (2014-06-06 21:24:10+00:00)
Title: Fix behavior of Redis client

Because HHVM forces auto_detect_line_ending to be enabled (which is a separate
bug), if a CRLF is split across two TCP packets, fgets() is liable to get
confused and assume that the stream uses CR line ending. As a result, the
return value of Redis::sockReadLine() is liable to have either a trailing CR or
a leading LF, both of which are corruptions. This causes the client to throw an
exception, complaining of a protocol error.

The behavior of fgets() is documented here:
http://www.php.net/manual/en/function.fgets.php#101963

The Redis protocol spec affirms that responses terminate with CRLF and are
guaranteed not to contain either CR or LF in the response body:
http://redis.io/topics/protocol