Http2FrameClient Class — netty Architecture
Architecture documentation for the Http2FrameClient class in Http2FrameClient.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a5f5ed7e_98fd_2a82_b26b_436a7df4740f["Http2FrameClient"] cce77157_4164_f39b_6304_b6d7c5f750a8["Http2FrameClient.java"] a5f5ed7e_98fd_2a82_b26b_436a7df4740f -->|defined in| cce77157_4164_f39b_6304_b6d7c5f750a8 2a19f26b_73f8_84e3_8089_599416af8b5b["Http2FrameClient()"] a5f5ed7e_98fd_2a82_b26b_436a7df4740f -->|method| 2a19f26b_73f8_84e3_8089_599416af8b5b 208fbeb3_d681_e118_a703_834a779c84d4["main()"] a5f5ed7e_98fd_2a82_b26b_436a7df4740f -->|method| 208fbeb3_d681_e118_a703_834a779c84d4
Relationship Graph
Source Code
example/src/main/java/io/netty/example/http2/helloworld/frame/client/Http2FrameClient.java lines 49–125
public final class Http2FrameClient {
static final boolean SSL = System.getProperty("ssl") != null;
static final String HOST = System.getProperty("host", "127.0.0.1");
static final int PORT = Integer.parseInt(System.getProperty("port", SSL? "8443" : "8080"));
static final String PATH = System.getProperty("path", "/");
private Http2FrameClient() {
}
public static void main(String[] args) throws Exception {
EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
// Configure SSL.
final SslContext sslCtx;
if (SSL) {
final SslProvider provider =
SslProvider.isAlpnSupported(SslProvider.OPENSSL)? SslProvider.OPENSSL : SslProvider.JDK;
sslCtx = SslContextBuilder.forClient()
.sslProvider(provider)
.ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
// you probably won't want to use this in production, but it is fine for this example:
.trustManager(InsecureTrustManagerFactory.INSTANCE)
.applicationProtocolConfig(new ApplicationProtocolConfig(
Protocol.ALPN,
SelectorFailureBehavior.NO_ADVERTISE,
SelectedListenerFailureBehavior.ACCEPT,
ApplicationProtocolNames.HTTP_2,
ApplicationProtocolNames.HTTP_1_1))
.build();
} else {
sslCtx = null;
}
try {
final Bootstrap b = new Bootstrap();
b.group(group);
b.channel(NioSocketChannel.class);
b.option(ChannelOption.SO_KEEPALIVE, true);
b.remoteAddress(HOST, PORT);
b.handler(new Http2ClientFrameInitializer(sslCtx));
// Start the client.
final Channel channel = b.connect().syncUninterruptibly().channel();
System.out.println("Connected to [" + HOST + ':' + PORT + ']');
final Http2ClientStreamFrameResponseHandler streamFrameResponseHandler =
new Http2ClientStreamFrameResponseHandler();
final Http2StreamChannelBootstrap streamChannelBootstrap = new Http2StreamChannelBootstrap(channel);
final Http2StreamChannel streamChannel = streamChannelBootstrap.open().syncUninterruptibly().getNow();
streamChannel.pipeline().addLast(streamFrameResponseHandler);
// Send request (a HTTP/2 HEADERS frame - with ':method = GET' in this case)
final DefaultHttp2Headers headers = new DefaultHttp2Headers();
headers.method("GET");
headers.path(PATH);
headers.scheme(SSL? "https" : "http");
final Http2HeadersFrame headersFrame = new DefaultHttp2HeadersFrame(headers, true);
streamChannel.writeAndFlush(headersFrame);
System.out.println("Sent HTTP/2 GET request to " + PATH);
// Wait for the responses (or for the latch to expire), then clean up the connections
if (!streamFrameResponseHandler.responseSuccessfullyCompleted()) {
System.err.println("Did not get HTTP/2 response in expected time.");
}
System.out.println("Finished HTTP/2 request, will close the connection.");
// Wait until the connection is closed.
channel.close().syncUninterruptibly();
} finally {
group.shutdownGracefully();
}
}
}
Defined In
Source
Frequently Asked Questions
What is the Http2FrameClient class?
Http2FrameClient is a class in the netty codebase, defined in example/src/main/java/io/netty/example/http2/helloworld/frame/client/Http2FrameClient.java.
Where is Http2FrameClient defined?
Http2FrameClient is defined in example/src/main/java/io/netty/example/http2/helloworld/frame/client/Http2FrameClient.java at line 49.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free