channelRead0() — netty Function Reference
Architecture documentation for the channelRead0() function in WebSocketIndexPageHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD bed3075c_486b_aa7a_c6e9_bbec68fb8e86["channelRead0()"] 8ea989dc_fe6f_0b1b_4077_4a12c09b3008["WebSocketIndexPageHandler"] bed3075c_486b_aa7a_c6e9_bbec68fb8e86 -->|defined in| 8ea989dc_fe6f_0b1b_4077_4a12c09b3008 966de156_0f8c_6b06_20a6_e0712003b649["sendHttpResponse()"] bed3075c_486b_aa7a_c6e9_bbec68fb8e86 -->|calls| 966de156_0f8c_6b06_20a6_e0712003b649 style bed3075c_486b_aa7a_c6e9_bbec68fb8e86 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
example/src/main/java/io/netty/example/http/websocketx/server/WebSocketIndexPageHandler.java lines 50–86
@Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
// Handle a bad request.
if (!req.decoderResult().isSuccess()) {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(req.protocolVersion(), BAD_REQUEST,
ctx.alloc().buffer(0)));
return;
}
// Handle websocket upgrade request.
if (req.headers().contains(HttpHeaderNames.UPGRADE, HttpHeaderValues.WEBSOCKET, true)) {
ctx.fireChannelRead(req.retain());
return;
}
// Allow only GET methods.
if (!GET.equals(req.method())) {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(req.protocolVersion(), FORBIDDEN,
ctx.alloc().buffer(0)));
return;
}
// Send the index page
if ("/".equals(req.uri()) || "/index.html".equals(req.uri())) {
String webSocketLocation = getWebSocketLocation(ctx.pipeline(), req, websocketPath);
ByteBuf content = WebSocketServerIndexPage.getContent(webSocketLocation);
FullHttpResponse res = new DefaultFullHttpResponse(req.protocolVersion(), OK, content);
res.headers().set(CONTENT_TYPE, "text/html; charset=UTF-8");
HttpUtil.setContentLength(res, content.readableBytes());
sendHttpResponse(ctx, req, res);
} else {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(req.protocolVersion(), NOT_FOUND,
ctx.alloc().buffer(0)));
}
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does channelRead0() do?
channelRead0() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/http/websocketx/server/WebSocketIndexPageHandler.java.
Where is channelRead0() defined?
channelRead0() is defined in example/src/main/java/io/netty/example/http/websocketx/server/WebSocketIndexPageHandler.java at line 50.
What does channelRead0() call?
channelRead0() calls 1 function(s): sendHttpResponse.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free