Http3SpecTestServer Class — netty Architecture
Architecture documentation for the Http3SpecTestServer class in Http3SpecTestServer.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 6b5e717a_e905_e589_643c_13da1e9700ea["Http3SpecTestServer"] d0bdef44_fedb_4e75_5bb4_d92c87985b13["Http3SpecTestServer.java"] 6b5e717a_e905_e589_643c_13da1e9700ea -->|defined in| d0bdef44_fedb_4e75_5bb4_d92c87985b13 e0fffcad_f651_5bde_df84_55f811fcdd3d["Http3SpecTestServer()"] 6b5e717a_e905_e589_643c_13da1e9700ea -->|method| e0fffcad_f651_5bde_df84_55f811fcdd3d 259854f0_14ff_ee35_e338_d863b35ef404["main()"] 6b5e717a_e905_e589_643c_13da1e9700ea -->|method| 259854f0_14ff_ee35_e338_d863b35ef404
Relationship Graph
Source Code
codec-http3/src/test/java/io/netty/handler/codec/http3/Http3SpecTestServer.java lines 40–118
public final class Http3SpecTestServer {
private static final byte[] CONTENT = "Hello World!\r\n".getBytes(CharsetUtil.US_ASCII);
static final int PORT = 9999;
private Http3SpecTestServer() { }
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);
}
});
}
}, null, null, null, true));
}
}).build();
try {
Bootstrap bs = new Bootstrap();
Channel channel = bs.group(group)
.channel(NioDatagramChannel.class)
.handler(codec)
.bind(new InetSocketAddress(port)).sync().channel();
channel.eventLoop().submit(() -> System.out.println("H3SPEC_SERVER_READY"));
channel.closeFuture().sync();
} finally {
group.shutdownGracefully();
}
}
}
Source
Frequently Asked Questions
What is the Http3SpecTestServer class?
Http3SpecTestServer is a class in the netty codebase, defined in codec-http3/src/test/java/io/netty/handler/codec/http3/Http3SpecTestServer.java.
Where is Http3SpecTestServer defined?
Http3SpecTestServer is defined in codec-http3/src/test/java/io/netty/handler/codec/http3/Http3SpecTestServer.java at line 40.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free