code: protected void handleHttpRequest(final ChannelHandlerContext channelContext, final HttpRequest request) throws Exception {
          if (isWebSocketsUpgradeRequest( request )) {
  
              final Handshake handshake = findHandshake( request );
  
              if (handshake != null) {
  
                  HttpResponse response = handshake.generateResponse( request );
  
                  response.addHeader( Names.UPGRADE, Values.WEBSOCKET );
                  response.addHeader( Names.CONNECTION, Values.UPGRADE );
  
                  final ChannelPipeline pipeline = channelContext.getChannel().getPipeline();
                  reconfigureUpstream( pipeline, handshake );
  
                  Channel channel = channelContext.getChannel();
                  ChannelFuture future = channel.write( response );
                  future.addListener( new ChannelFutureListener() {
                      public void operationComplete(ChannelFuture future) throws Exception {
                          reconfigureDownstream( pipeline, handshake );
                          pipeline.replace( ServerHandshakeHandler.this, "websocket-disconnection-negotiator", new WebSocketDisconnectionNegotiator() );
                          forwardConnectEventUpstream( channelContext );
                          decodeHost( channelContext, request );
                          decodeSession( channelContext, request );
                      }
                  } );
  
                  return;
              }
          }
  
          // Send an error page otherwise.
          sendHttpResponse( channelContext, request, new DefaultHttpResponse( HttpVersion.HTTP_1_1, HttpResponseStatus.FORBIDDEN ) );
      }
docs: Handle initial HTTP portion of the handshake.
  
  @param channelContext
  @param request
  @throws Exception