HelloWorldHttp1Handler Class — netty Architecture
Architecture documentation for the HelloWorldHttp1Handler class in HelloWorldHttp1Handler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD f95b74b1_4022_4234_ac28_b2c846d5eeb9["HelloWorldHttp1Handler"] f55ed1ed_36b8_42e2_4529_f7bda94a3bdb["HelloWorldHttp1Handler.java"] f95b74b1_4022_4234_ac28_b2c846d5eeb9 -->|defined in| f55ed1ed_36b8_42e2_4529_f7bda94a3bdb 576ccc27_8400_d79a_c712_e9345f175dd7["HelloWorldHttp1Handler()"] f95b74b1_4022_4234_ac28_b2c846d5eeb9 -->|method| 576ccc27_8400_d79a_c712_e9345f175dd7 330baa21_2718_139e_7525_9e881786420a["channelRead0()"] f95b74b1_4022_4234_ac28_b2c846d5eeb9 -->|method| 330baa21_2718_139e_7525_9e881786420a caaa8fcd_af50_b811_61a6_73def695a342["channelReadComplete()"] f95b74b1_4022_4234_ac28_b2c846d5eeb9 -->|method| caaa8fcd_af50_b811_61a6_73def695a342 dd99fe3a_17f4_e823_e4d0_a4710b0519a2["exceptionCaught()"] f95b74b1_4022_4234_ac28_b2c846d5eeb9 -->|method| dd99fe3a_17f4_e823_e4d0_a4710b0519a2
Relationship Graph
Source Code
testsuite-http2/src/main/java/io/netty/testsuite/http2/HelloWorldHttp1Handler.java lines 40–80
public class HelloWorldHttp1Handler extends SimpleChannelInboundHandler<FullHttpRequest> {
private final String establishApproach;
HelloWorldHttp1Handler(String establishApproach) {
this.establishApproach = checkNotNull(establishApproach, "establishApproach");
}
@Override
public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
if (HttpUtil.is100ContinueExpected(req)) {
ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE, ctx.alloc().buffer(0)));
}
boolean keepAlive = HttpUtil.isKeepAlive(req);
ByteBuf content = ctx.alloc().buffer();
content.writeBytes(HelloWorldHttp2Handler.RESPONSE_BYTES.duplicate());
ByteBufUtil.writeAscii(content, " - via " + req.protocolVersion() + " (" + establishApproach + ")");
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK, content);
response.headers().set(CONTENT_TYPE, "text/plain; charset=UTF-8");
response.headers().setInt(CONTENT_LENGTH, response.content().readableBytes());
if (!keepAlive) {
ctx.write(response).addListener(ChannelFutureListener.CLOSE);
} else {
response.headers().set(CONNECTION, HttpHeaderValues.KEEP_ALIVE);
ctx.write(response);
}
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
ctx.flush();
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
}
Source
Frequently Asked Questions
What is the HelloWorldHttp1Handler class?
HelloWorldHttp1Handler is a class in the netty codebase, defined in testsuite-http2/src/main/java/io/netty/testsuite/http2/HelloWorldHttp1Handler.java.
Where is HelloWorldHttp1Handler defined?
HelloWorldHttp1Handler is defined in testsuite-http2/src/main/java/io/netty/testsuite/http2/HelloWorldHttp1Handler.java at line 40.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free