Example usage for io.netty.handler.codec.http2 HttpToHttp2ConnectionHandlerBuilder build

List of usage examples for io.netty.handler.codec.http2 HttpToHttp2ConnectionHandlerBuilder build

Introduction

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

Prototype

@Override
    public HttpToHttp2ConnectionHandler build() 

Source Link

Usage

From source file:com.vmware.xenon.common.http.netty.NettyHttpServerInitializer.java

License:Open Source License

/**
 * For HTTP/2 we don't have anything as simple as the HttpServerCodec (at least, not in Netty
 * 5.0alpha 2), so we create the equivalent.
 *
 * @return//from   w  w w.  j  av  a2  s .  c  o  m
 */
private HttpToHttp2ConnectionHandler makeHttp2ConnectionHandler() {
    // DefaultHttp2Connection is for client or server. True means "server".
    Http2Connection connection = new DefaultHttp2Connection(true);
    InboundHttp2ToHttpAdapter inboundAdapter = new InboundHttp2ToHttpAdapterBuilder(connection)
            .maxContentLength(this.responsePayloadSizeLimit).propagateSettings(false).build();
    DelegatingDecompressorFrameListener frameListener = new DelegatingDecompressorFrameListener(connection,
            inboundAdapter);

    Http2Settings settings = new Http2Settings();
    //settings.maxConcurrentStreams(NettyHttpServiceClient.DEFAULT_HTTP2_STREAMS_PER_HOST);
    settings.initialWindowSize(NettyChannelContext.INITIAL_HTTP2_WINDOW_SIZE);

    HttpToHttp2ConnectionHandlerBuilder builder = new HttpToHttp2ConnectionHandlerBuilder()
            .frameListener(frameListener).initialSettings(settings).connection(connection);

    if (debugLogging) {
        Http2FrameLogger frameLogger = new Http2FrameLogger(LogLevel.INFO,
                NettyHttpClientRequestInitializer.class);
        builder.frameLogger(frameLogger);
    }

    HttpToHttp2ConnectionHandler connectionHandler = builder.build();

    return connectionHandler;
}