Skip to main content

parse_command

Function parse_command 

Source
pub fn parse_command(buffer: &[u8]) -> Parsed
Expand description

Try to take one command from the front of buffer.

Framing rules that matter, and that are easy to get wrong:

  • Every command line ends with \r\n. A bare \n is not accepted; upstream is lenient about this in places but a strict server keeps clients honest and keeps byte counting unambiguous.
  • A storage command is followed by exactly <bytes> octets and then \r\n. The count is authoritative: the data block may itself contain \r\n, so scanning for a delimiter instead of counting is the classic memcached implementation bug.