Example usage for io.netty.handler.codec.http2 Http2FrameCodecBuilder forServer

List of usage examples for io.netty.handler.codec.http2 Http2FrameCodecBuilder forServer

Introduction

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

Prototype

public static Http2FrameCodecBuilder forServer() 

Source Link

Document

Creates a builder for an HTTP/2 server.

Usage

From source file:example.http2.helloworld.frame.server.Http2OrHttpHandler.java

License:Apache License

@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
    if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
        ctx.pipeline().addLast(Http2FrameCodecBuilder.forServer().build(), new HelloWorldHttp2Handler());
        return;/*www.j a  v  a  2s . c  o  m*/
    }

    if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
        ctx.pipeline().addLast(new HttpServerCodec(), new HttpObjectAggregator(MAX_CONTENT_LENGTH),
                new HelloWorldHttp1Handler("ALPN Negotiation"));
        return;
    }

    throw new IllegalStateException("unknown protocol: " + protocol);
}

From source file:io.netty.example.http2.helloworld.multiplex.server.Http2OrHttpHandler.java

License:Apache License

@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
    if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
        ctx.pipeline().addLast(Http2FrameCodecBuilder.forServer().build());
        ctx.pipeline().addLast(new Http2MultiplexHandler(new HelloWorldHttp2Handler()));
        return;// w w  w .  ja  v  a2  s. co  m
    }

    if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
        ctx.pipeline().addLast(new HttpServerCodec(), new HttpObjectAggregator(MAX_CONTENT_LENGTH),
                new HelloWorldHttp1Handler("ALPN Negotiation"));
        return;
    }

    throw new IllegalStateException("unknown protocol: " + protocol);
}