Example usage for io.netty.handler.codec.http2 Http2ClientUpgradeCodec Http2ClientUpgradeCodec

List of usage examples for io.netty.handler.codec.http2 Http2ClientUpgradeCodec Http2ClientUpgradeCodec

Introduction

In this page you can find the example usage for io.netty.handler.codec.http2 Http2ClientUpgradeCodec Http2ClientUpgradeCodec.

Prototype

public Http2ClientUpgradeCodec(String handlerName, Http2ConnectionHandler connectionHandler) 

Source Link

Document

Creates the codec providing an upgrade to the given handler for HTTP/2.

Usage

From source file:io.bsoa.rpc.grpc.client12.Http2ClientInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) throws Exception {
    final Http2Connection connection = new DefaultHttp2Connection(false);
    connectionHandler = new HttpToHttp2ConnectionHandlerBuilder()
            .frameListener(new DelegatingDecompressorFrameListener(connection,
                    new InboundHttp2ToHttpAdapterBuilder(connection).maxContentLength(maxContentLength)
                            .propagateSettings(true).build()))
            .frameLogger(logger).connection(connection).build();
    responseHandler = new HttpResponseHandler();
    settingsHandler = new Http2SettingsHandler(ch.newPromise());

    HttpClientCodec sourceCodec = new HttpClientCodec();
    Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec("connectionHandler", connectionHandler);
    HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, 65536);

    ch.pipeline().addLast("sourceCodec?", sourceCodec);
    ch.pipeline().addLast("upgradeHandlerupgrade", upgradeHandler);
    ch.pipeline().addLast("UpgradeRequestHandler?upgrade", new UpgradeRequestHandler());
    ch.pipeline().addLast("UserEventLogger", new UserEventLogger());

    System.out.println("======1=======>" + ch.pipeline().names() + "<=========" + ch.pipeline().toMap());
}