protected final void channelRead0()

in zuul-core/src/main/java/com/netflix/zuul/netty/server/push/PushAuthHandler.java [74:103]


    protected final void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) {
        if (!Objects.equals(req.method(), HttpMethod.GET)) {
            sendHttpResponse(req, ctx, HttpResponseStatus.METHOD_NOT_ALLOWED);
            return;
        }

        String path = req.uri();
        if (Objects.equals(path, "/healthcheck")) {
            sendHttpResponse(req, ctx, HttpResponseStatus.OK);
        } else if (pushConnectionPath.equals(path)) {
            // CSRF protection
            if (isInvalidOrigin(req)) {
                sendHttpResponse(req, ctx, HttpResponseStatus.BAD_REQUEST);
            } else if (isDelayedAuth(req, ctx)) {
                // client auth will happen later, continue with WebSocket upgrade handshake
                ctx.fireChannelRead(req.retain());
            } else {
                PushUserAuth authEvent = doAuth(req, ctx);
                if (authEvent.isSuccess()) {
                    ctx.fireChannelRead(req.retain()); // continue with WebSocket upgrade handshake
                    ctx.fireUserEventTriggered(authEvent);
                } else {
                    logger.warn("Auth failed: {}", authEvent.statusCode());
                    sendHttpResponse(req, ctx, HttpResponseStatus.valueOf(authEvent.statusCode()));
                }
            }
        } else {
            sendHttpResponse(req, ctx, HttpResponseStatus.NOT_FOUND);
        }
    }