public void userEventTriggered()

in zuul-core/src/main/java/com/netflix/zuul/netty/server/ClientResponseWriter.java [216:262]


    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        if (evt instanceof StartEvent) {
            isHandlingRequest = true;
            startedSendingResponseToClient = false;
            closeConnection = false;
            zuulResponse = null;
        } else if (evt instanceof CompleteEvent) {
            HttpResponse response = ((CompleteEvent) evt).getResponse();
            if (response != null) {
                if ("close".equalsIgnoreCase(response.headers().get("Connection"))) {
                    closeConnection = true;
                }
            }
            if (zuulResponse != null) {
                zuulResponse.disposeBufferedBody();
            }

            // Do all the post-completion metrics and logging.
            handleComplete(ctx.channel());

            // Choose to either close the connection, or prepare it for next use.
            CompleteEvent completeEvent = (CompleteEvent) evt;
            CompleteReason reason = completeEvent.getReason();
            if (reason == CompleteReason.SESSION_COMPLETE || reason == CompleteReason.INACTIVE) {
                if (!closeConnection) {
                    // Start reading next request over HTTP 1.1 persistent connection
                    ctx.channel().read();
                } else {
                    ctx.close();
                }
            } else {
                if (isHandlingRequest) {
                    logger.debug(
                            "Received complete event while still handling the request. With reason: {} -- {}",
                            reason.name(),
                            ChannelUtils.channelInfoForLogging(ctx.channel()));
                }
                ctx.close();
            }

            isHandlingRequest = false;
        } else if (evt instanceof IdleStateEvent) {
            logger.debug("Received IdleStateEvent.");
        } else {
            logger.debug("ClientResponseWriter Received event {}", evt);
        }
    }