Http3ServerExample Class — netty Architecture
Architecture documentation for the Http3ServerExample class in Http3ServerExample.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b0d82e76_b8b0_5a91_b7d9_427812f4c5a7["Http3ServerExample"] 8811f55c_9d7b_324e_bc10_f2fa1cc44c29["Http3ServerExample.java"] b0d82e76_b8b0_5a91_b7d9_427812f4c5a7 -->|defined in| 8811f55c_9d7b_324e_bc10_f2fa1cc44c29 a4cab888_f5e7_b4a1_79a5_9feb4926a0c5["Http3ServerExample()"] b0d82e76_b8b0_5a91_b7d9_427812f4c5a7 -->|method| a4cab888_f5e7_b4a1_79a5_9feb4926a0c5 f702a2f5_196d_3f71_a155_01475629b760["main()"] b0d82e76_b8b0_5a91_b7d9_427812f4c5a7 -->|method| f702a2f5_196d_3f71_a155_01475629b760
Relationship Graph
Source Code
codec-http3/src/test/java/io/netty/handler/codec/http3/example/Http3ServerExample.java lines 47–123
public final class Http3ServerExample {
private static final byte[] CONTENT = "Hello World!\r\n".getBytes(CharsetUtil.US_ASCII);
static final int PORT = 9999;
private Http3ServerExample() { }
public static void main(String... args) throws Exception {
int port;
// Allow to pass in the port so we can also use it to run h3spec against
if (args.length == 1) {
port = Integer.parseInt(args[0]);
} else {
port = PORT;
}
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory());
SelfSignedCertificate cert = new SelfSignedCertificate();
QuicSslContext sslContext = QuicSslContextBuilder.forServer(cert.key(), null, cert.cert())
.applicationProtocols(Http3.supportedApplicationProtocols()).build();
ChannelHandler codec = Http3.newQuicServerCodecBuilder()
.sslContext(sslContext)
.maxIdleTimeout(5000, TimeUnit.MILLISECONDS)
.initialMaxData(10000000)
.initialMaxStreamDataBidirectionalLocal(1000000)
.initialMaxStreamDataBidirectionalRemote(1000000)
.initialMaxStreamsBidirectional(100)
.tokenHandler(InsecureQuicTokenHandler.INSTANCE)
.handler(new ChannelInitializer<QuicChannel>() {
@Override
protected void initChannel(QuicChannel ch) {
// Called for each connection
ch.pipeline().addLast(new Http3ServerConnectionHandler(
new ChannelInitializer<QuicStreamChannel>() {
// Called for each request-stream,
@Override
protected void initChannel(QuicStreamChannel ch) {
ch.pipeline().addLast(new Http3RequestStreamInboundHandler() {
@Override
protected void channelRead(
ChannelHandlerContext ctx, Http3HeadersFrame frame) {
ReferenceCountUtil.release(frame);
}
@Override
protected void channelRead(
ChannelHandlerContext ctx, Http3DataFrame frame) {
ReferenceCountUtil.release(frame);
}
@Override
protected void channelInputClosed(ChannelHandlerContext ctx) {
Http3HeadersFrame headersFrame = new DefaultHttp3HeadersFrame();
headersFrame.headers().status("404");
headersFrame.headers().add("server", "netty");
headersFrame.headers().addInt("content-length", CONTENT.length);
ctx.write(headersFrame);
ctx.writeAndFlush(new DefaultHttp3DataFrame(
Unpooled.wrappedBuffer(CONTENT)))
.addListener(QuicStreamChannel.SHUTDOWN_OUTPUT);
}
});
}
}));
}
}).build();
try {
Bootstrap bs = new Bootstrap();
Channel channel = bs.group(group)
.channel(NioDatagramChannel.class)
.handler(codec)
.bind(new InetSocketAddress(port)).sync().channel();
channel.closeFuture().sync();
} finally {
group.shutdownGracefully();
}
}
}
Source
Frequently Asked Questions
What is the Http3ServerExample class?
Http3ServerExample is a class in the netty codebase, defined in codec-http3/src/test/java/io/netty/handler/codec/http3/example/Http3ServerExample.java.
Where is Http3ServerExample defined?
Http3ServerExample is defined in codec-http3/src/test/java/io/netty/handler/codec/http3/example/Http3ServerExample.java at line 47.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free