Home / Function/ runClient() — netty Function Reference

runClient() — netty Function Reference

Architecture documentation for the runClient() function in CodecHttp3Test.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  0ab38458_0c2c_d279_6635_52895d2e6ba2["runClient()"]
  6c8fb13b_b80f_3665_36aa_58857fdc6fd3["CodecHttp3Test"]
  0ab38458_0c2c_d279_6635_52895d2e6ba2 -->|defined in| 6c8fb13b_b80f_3665_36aa_58857fdc6fd3
  b90b60f1_89bf_213e_bf97_5dd0f3118f5a["smokeTest()"]
  b90b60f1_89bf_213e_bf97_5dd0f3118f5a -->|calls| 0ab38458_0c2c_d279_6635_52895d2e6ba2
  style 0ab38458_0c2c_d279_6635_52895d2e6ba2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/CodecHttp3Test.java lines 75–138

    private void runClient(EventLoopGroup group, int port) throws InterruptedException, ExecutionException {
        QuicSslContext context = QuicSslContextBuilder.forClient()
                .trustManager(InsecureTrustManagerFactory.INSTANCE)
                .applicationProtocols(Http3.supportedApplicationProtocols()).build();
        ChannelHandler codec = Http3.newQuicClientCodecBuilder()
                .sslContext(context)
                .maxIdleTimeout(5000, TimeUnit.MILLISECONDS)
                .initialMaxData(10000000)
                .initialMaxStreamDataBidirectionalLocal(1000000)
                .build();

        Bootstrap bs = new Bootstrap();
        Channel channel = bs.group(group)
                .channel(NioDatagramChannel.class)
                .handler(codec)
                .bind(0).sync().channel();

        QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
                .handler(new Http3ClientConnectionHandler())
                .remoteAddress(new InetSocketAddress(NetUtil.LOCALHOST4, port))
                .connect()
                .get();

        CompletableFuture<String> response = new CompletableFuture<>();

        QuicStreamChannel streamChannel = Http3.newRequestStream(quicChannel,
                new Http3RequestStreamInboundHandler() {

                    @Override
                    protected void channelRead(ChannelHandlerContext ctx, Http3HeadersFrame frame) {
                        ReferenceCountUtil.release(frame);
                    }

                    @Override
                    protected void channelRead(ChannelHandlerContext ctx, Http3DataFrame frame) {
                        response.complete(frame.content().toString(CharsetUtil.US_ASCII));
                        ReferenceCountUtil.release(frame);
                    }

                    @Override
                    protected void channelInputClosed(ChannelHandlerContext ctx) {
                        ctx.close();
                    }
                }).sync().getNow();

        // Write the Header frame and send the FIN to mark the end of the request.
        // After this its not possible anymore to write any more data.
        Http3HeadersFrame frame = new DefaultHttp3HeadersFrame();
        frame.headers().method("GET").path("/")
                .authority(NetUtil.LOCALHOST4.getHostAddress() + ":" + port)
                .scheme("https");
        streamChannel.writeAndFlush(frame)
                .addListener(QuicStreamChannel.SHUTDOWN_OUTPUT).sync();

        // Wait for the stream channel and quic channel to be closed (this will happen after we received the FIN).
        // After this is done we will close the underlying datagram channel.
        streamChannel.closeFuture().sync();

        assertEquals("Hello World!\r\n", response.get());

        // After we received the response lets also close the underlying QUIC channel and datagram channel.
        quicChannel.close().sync();
        channel.close().sync();
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does runClient() do?
runClient() is a function in the netty codebase, defined in testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/CodecHttp3Test.java.
Where is runClient() defined?
runClient() is defined in testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/CodecHttp3Test.java at line 75.
What calls runClient()?
runClient() is called by 1 function(s): smokeTest.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free