code: private static ChannelBuffer createDataTerminatingChannelBuffer(byte[] data) {
          int length = data.length;
          if (length < 1) {
              return ChannelBuffers.wrappedBuffer(CRLF_DOT_CRLF);
          } else {
              byte[] terminating;
  
              byte last = data[length -1];
  
              if (length == 1) {
                  if (last == CR) {
                      terminating = LF_DOT_CRLF;
                  } else {
                      terminating = CRLF_DOT_CRLF;
                  }
              } else {
                  byte prevLast = data[length - 2];
                  
                  if (last == LF) {
                      if (prevLast == CR) {
                          terminating = DOT_CRLF;
                      } else {
                          terminating = CRLF_DOT_CRLF;
                      }
                  } else if (last == CR) {
                      terminating = LF_DOT_CRLF;
                  } else {
                      terminating = CRLF_DOT_CRLF;
  
                  }
              }
              return ChannelBuffers.wrappedBuffer(data, terminating);
          }
          
        
      }
docs: Create a {@link ChannelBuffer} which is terminated with a CRLF.CRLF sequence
  
  @param data
  @return buffer