code: @Override
      public void messageReceived(final NextFilter nextFilter,
              final IoSession session, final Object message)
              throws ProxyAuthException {
          ProxyLogicHandler handler = getProxyHandler(session);
  
          synchronized (handler) {
              IoBuffer buf = (IoBuffer) message;
  
              if (handler.isHandshakeComplete()) {
                  // Handshake done - pass data on as-is
                  nextFilter.messageReceived(session, buf);
  
              } else {
                  LOGGER.debug(" Data Read: {} ({})", handler, buf);
  
                  // Keep sending handshake data to the handler until we run out
                  // of data or the handshake is finished
                  while (buf.hasRemaining() && !handler.isHandshakeComplete()) {
                      LOGGER.debug(" Pre-handshake - passing to handler");
  
                      int pos = buf.position();
                      handler.messageReceived(nextFilter, buf);
  
                      // Data not consumed or session closing
                      if (buf.position() == pos || session.isClosing()) {
                          return;
                      }
                  }
  
                  // Pass on any remaining data to the next filter
                  if (buf.hasRemaining()) {
                      LOGGER.debug(" Passing remaining data to next filter");
  
                      nextFilter.messageReceived(session, buf);
                  }
              }
          }
      }
docs: Receives data from the remote host, passes to the handler if a handshake is in progress,
  otherwise passes on transparently.
  
  @param nextFilter the next filter in filter chain
  @param session the session object
  @param message the object holding the received data