private ByteBuffer readLine()

in folsom/src/main/java/com/spotify/folsom/client/ascii/AsciiMemcacheDecoder.java [296:314]


  private ByteBuffer readLine(final ByteBuf buf, final int available) throws IOException {
    if (consumed) {
      consumed = false;
      line.clear();
    }
    for (int i = 0; i < available - 1; i++) {
      final byte b = buf.readByte();
      if (b == '\r') {
        if (buf.readByte() == '\n') {
          consumed = true;
          line.flip();
          return line;
        }
        throw new IOException("Expected newline, got something else");
      }
      line.put(b);
    }
    return null;
  }