Home / Function/ channelRead() — netty Function Reference

channelRead() — netty Function Reference

Architecture documentation for the channelRead() function in Utf8FrameValidator.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  95417fd6_697c_ee9f_be0e_5cdc60d7350f["channelRead()"]
  703786e3_a739_d459_7ab0_6451a2d19cdf["Utf8FrameValidator"]
  95417fd6_697c_ee9f_be0e_5cdc60d7350f -->|defined in| 703786e3_a739_d459_7ab0_6451a2d19cdf
  b1f436ed_fa46_f58e_f1be_408bd00463e5["isControlFrame()"]
  95417fd6_697c_ee9f_be0e_5cdc60d7350f -->|calls| b1f436ed_fa46_f58e_f1be_408bd00463e5
  c5a4f50d_2576_9eef_f670_a6dba4a8f68b["checkUTF8String()"]
  95417fd6_697c_ee9f_be0e_5cdc60d7350f -->|calls| c5a4f50d_2576_9eef_f670_a6dba4a8f68b
  07b6a241_43f6_47fc_892d_87fcedabf99a["protocolViolation()"]
  95417fd6_697c_ee9f_be0e_5cdc60d7350f -->|calls| 07b6a241_43f6_47fc_892d_87fcedabf99a
  style 95417fd6_697c_ee9f_be0e_5cdc60d7350f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/websocketx/Utf8FrameValidator.java lines 48–99

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        if (msg instanceof WebSocketFrame) {
            WebSocketFrame frame = (WebSocketFrame) msg;

            try {
                // Processing for possible fragmented messages for text and binary
                // frames
                if (frame.isFinalFragment()) {
                    // Control frames are allowed between fragments
                    // See https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.
                    if (!isControlFrame(frame)) {

                        // Final frame of the sequence.
                        fragmentedFramesCount = 0;

                        // Check text for UTF8 correctness
                        if (frame instanceof TextWebSocketFrame ||
                                (utf8Validator != null && utf8Validator.isChecking())) {
                            // Check UTF-8 correctness for this payload
                            checkUTF8String(frame.content());

                            // This does a second check to make sure UTF-8
                            // correctness for entire text message
                            utf8Validator.finish();
                        }
                    }
                } else {
                    // Not final frame so we can expect more frames in the
                    // fragmented sequence
                    if (fragmentedFramesCount == 0) {
                        // First text or binary frame for a fragmented set
                        if (frame instanceof TextWebSocketFrame) {
                            checkUTF8String(frame.content());
                        }
                    } else {
                        // Subsequent frames - only check if init frame is text
                        if (utf8Validator != null && utf8Validator.isChecking()) {
                            checkUTF8String(frame.content());
                        }
                    }

                    // Increment counter
                    fragmentedFramesCount++;
                }
            } catch (CorruptedWebSocketFrameException e) {
                protocolViolation(ctx, frame, e);
            }
        }

        super.channelRead(ctx, msg);
    }

Subdomains

Frequently Asked Questions

What does channelRead() do?
channelRead() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/Utf8FrameValidator.java.
Where is channelRead() defined?
channelRead() is defined in codec-http/src/main/java/io/netty/handler/codec/http/websocketx/Utf8FrameValidator.java at line 48.
What does channelRead() call?
channelRead() calls 3 function(s): checkUTF8String, isControlFrame, protocolViolation.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free