channelRead0() — netty Function Reference
Architecture documentation for the channelRead0() function in HttpSnoopServerHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 38a6ac21_703f_7d5d_2772_e7831e8a40e0["channelRead0()"] 0dc0edc6_a74a_0a99_9be5_a85731fba901["HttpSnoopServerHandler"] 38a6ac21_703f_7d5d_2772_e7831e8a40e0 -->|defined in| 0dc0edc6_a74a_0a99_9be5_a85731fba901 d078845a_94ac_2931_f123_c42b07e3a660["send100Continue()"] 38a6ac21_703f_7d5d_2772_e7831e8a40e0 -->|calls| d078845a_94ac_2931_f123_c42b07e3a660 0aad675e_3307_6c46_ca2d_aa6d08dda7eb["appendDecoderResult()"] 38a6ac21_703f_7d5d_2772_e7831e8a40e0 -->|calls| 0aad675e_3307_6c46_ca2d_aa6d08dda7eb 47526183_e8b0_7ed5_2265_4a4123e1c6fb["writeResponse()"] 38a6ac21_703f_7d5d_2772_e7831e8a40e0 -->|calls| 47526183_e8b0_7ed5_2265_4a4123e1c6fb style 38a6ac21_703f_7d5d_2772_e7831e8a40e0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java lines 59–134
@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof HttpRequest) {
HttpRequest request = this.request = (HttpRequest) msg;
if (HttpUtil.is100ContinueExpected(request)) {
send100Continue(ctx);
}
buf.setLength(0);
buf.append("WELCOME TO THE WILD WILD WEB SERVER\r\n");
buf.append("===================================\r\n");
buf.append("VERSION: ").append(request.protocolVersion()).append("\r\n");
buf.append("HOSTNAME: ").append(request.headers().get(HttpHeaderNames.HOST, "unknown")).append("\r\n");
buf.append("REQUEST_URI: ").append(request.uri()).append("\r\n\r\n");
HttpHeaders headers = request.headers();
if (!headers.isEmpty()) {
for (Map.Entry<String, String> h: headers) {
CharSequence key = h.getKey();
CharSequence value = h.getValue();
buf.append("HEADER: ").append(key).append(" = ").append(value).append("\r\n");
}
buf.append("\r\n");
}
QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.uri());
Map<String, List<String>> params = queryStringDecoder.parameters();
if (!params.isEmpty()) {
for (Entry<String, List<String>> p: params.entrySet()) {
String key = p.getKey();
List<String> vals = p.getValue();
for (String val : vals) {
buf.append("PARAM: ").append(key).append(" = ").append(val).append("\r\n");
}
}
buf.append("\r\n");
}
appendDecoderResult(buf, request);
}
if (msg instanceof HttpContent) {
HttpContent httpContent = (HttpContent) msg;
ByteBuf content = httpContent.content();
if (content.isReadable()) {
buf.append("CONTENT: ");
buf.append(content.toString(CharsetUtil.UTF_8));
buf.append("\r\n");
appendDecoderResult(buf, request);
}
if (msg instanceof LastHttpContent) {
buf.append("END OF CONTENT\r\n");
LastHttpContent trailer = (LastHttpContent) msg;
if (!trailer.trailingHeaders().isEmpty()) {
buf.append("\r\n");
for (CharSequence name: trailer.trailingHeaders().names()) {
for (CharSequence value: trailer.trailingHeaders().getAll(name)) {
buf.append("TRAILING HEADER: ");
buf.append(name).append(" = ").append(value).append("\r\n");
}
}
buf.append("\r\n");
}
if (!writeResponse(trailer, ctx)) {
// If keep-alive is off, close the connection once the content is fully written.
ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
}
}
}
Domain
Subdomains
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/snoop/HttpSnoopServerHandler.java.
Where is channelRead0() defined?
channelRead0() is defined in example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java at line 59.
What does channelRead0() call?
channelRead0() calls 3 function(s): appendDecoderResult, send100Continue, writeResponse.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free