Example usage for io.netty.handler.codec.http2 Http2CodecUtil HTTP_UPGRADE_SETTINGS_HEADER

List of usage examples for io.netty.handler.codec.http2 Http2CodecUtil HTTP_UPGRADE_SETTINGS_HEADER

Introduction

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

Prototype

CharSequence HTTP_UPGRADE_SETTINGS_HEADER

To view the source code for io.netty.handler.codec.http2 Http2CodecUtil HTTP_UPGRADE_SETTINGS_HEADER.

Click Source Link

Usage

From source file:com.linecorp.armeria.server.http.Http1RequestDecoder.java

License:Apache License

@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
    if (evt instanceof UpgradeEvent) {
        // Generate the initial Http2Settings frame,
        // so that the next handler knows the protocol upgrade occurred as well.
        ctx.fireChannelRead(DEFAULT_HTTP2_SETTINGS);

        // Continue handling the upgrade request after the upgrade is complete.
        final FullHttpRequest nettyReq = ((UpgradeEvent) evt).upgradeRequest();

        // Remove the headers related with the upgrade.
        nettyReq.headers().remove(HttpHeaderNames.CONNECTION);
        nettyReq.headers().remove(HttpHeaderNames.UPGRADE);
        nettyReq.headers().remove(Http2CodecUtil.HTTP_UPGRADE_SETTINGS_HEADER);

        if (logger.isDebugEnabled()) {
            logger.debug("{} Handling the pre-upgrade request ({}): {} {} {} ({}B)", ctx.channel(),
                    ((UpgradeEvent) evt).protocol(), nettyReq.method(), nettyReq.uri(),
                    nettyReq.protocolVersion(), nettyReq.content().readableBytes());
        }//from  www.  j  a  v a  2 s  .com

        channelRead(ctx, nettyReq);
        channelReadComplete(ctx);
        return;
    }

    ctx.fireUserEventTriggered(evt);
}