protected static boolean fireCompleteEventIfNotAlready(ChannelHandlerContext ctx, CompleteReason reason) {
        // Only allow this method to run once per request.
        Attribute<State> attr = ctx.channel().attr(ATTR_STATE);
        State state = attr.get();

        if (state == null || state != State.STARTED) {
            return false;
        }

        attr.set(State.COMPLETED);

        HttpRequest request = ctx.channel().attr(ATTR_HTTP_REQ).get();
        HttpResponse response = ctx.channel().attr(ATTR_HTTP_RESP).get();

        // Cleanup channel attributes.
        ctx.channel().attr(ATTR_HTTP_REQ).set(null);
        ctx.channel().attr(ATTR_HTTP_RESP).set(null);

        // Fire the event to whole pipeline.
        ctx.pipeline().fireUserEventTriggered(new CompleteEvent(reason, request, response));

        return true;
    }
User: michaels@netflix.com
Date: 5/24/16
Time: 4:09 PM
zuul-core/src/main/java/com/netflix/netty/common/HttpLifecycleChannelHandler.java