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

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

Introduction

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

Prototype

public DefaultHttp2Connection(boolean server) 

Source Link

Document

Creates a new connection with the given settings.

Usage

From source file:Http2ClientConnectionHandler.java

License:Apache License

public Http2ClientConnectionHandler(ChannelPromise initPromise) {
    this(initPromise, new DefaultHttp2Connection(false));
}

From source file:HelloWorldHttp2Handler.java

License:Apache License

public HelloWorldHttp2Handler() {
    this(new DefaultHttp2Connection(true));
}

From source file:ccwihr.client.t2.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());
    if (sslCtx != null) {
        configureSsl(ch);//from   www  .  j  a v  a  2s  .c  o  m
    } else {
        configureClearText(ch);
    }
}

From source file:cn.jpush.api.common.connection.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(mNettyHttp2Client);
    settingsHandler = new Http2SettingsHandler(ch.newPromise());
    if (sslCtx != null) {
        configureSsl(ch);//from  w  w w  .  java 2  s .c om
    } else {
        configureClearText(ch);
    }
}

From source file:com.flysoloing.learning.network.netty.http2.tiles.Http2OrHttpHandler.java

License:Apache License

private static void configureHttp2(ChannelHandlerContext ctx) {
    DefaultHttp2Connection connection = new DefaultHttp2Connection(true);
    InboundHttp2ToHttpAdapter listener = new InboundHttp2ToHttpAdapterBuilder(connection)
            .propagateSettings(true).validateHttpHeaders(false).maxContentLength(MAX_CONTENT_LENGTH).build();

    ctx.pipeline().addLast(new HttpToHttp2ConnectionHandlerBuilder().frameListener(listener)
            // .frameLogger(TilesHttp2ToHttpHandler.logger)
            .connection(connection).build());

    ctx.pipeline().addLast(new Http2RequestHandler());
}

From source file:com.hop.hhxx.example.http2.helloworld.client.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 io.netty.example.http2.helloworld.client.HttpResponseHandler();
    settingsHandler = new io.netty.example.http2.helloworld.client.Http2SettingsHandler(ch.newPromise());
    if (sslCtx != null) {
        configureSsl(ch);//from   w  ww.j  a  v a  2  s  .com
    } else {
        configureClearText(ch);
    }
}

From source file:com.linecorp.armeria.client.http.HttpClientPipelineConfigurator.java

License:Apache License

private Http2ClientConnectionHandler newHttp2ConnectionHandler(Channel ch) {
    final boolean validateHeaders = false;
    final Http2Connection conn = new DefaultHttp2Connection(false);
    conn.addListener(new Http2GoAwayListener(ch));

    Http2FrameReader reader = new DefaultHttp2FrameReader(validateHeaders);
    Http2FrameWriter writer = new DefaultHttp2FrameWriter();

    Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(conn, writer);
    Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(conn, encoder, reader);

    final Http2ResponseDecoder listener = new Http2ResponseDecoder(ch);

    final Http2ClientConnectionHandler handler = new Http2ClientConnectionHandler(decoder, encoder,
            new Http2Settings(), listener);

    // Setup post build options
    handler.gracefulShutdownTimeoutMillis(options.idleTimeoutMillis());

    return handler;
}

From source file:com.linecorp.armeria.client.HttpClientPipelineConfigurator.java

License:Apache License

private Http2ClientConnectionHandler newHttp2ConnectionHandler(Channel ch) {
    final boolean validateHeaders = false;
    final Http2Connection conn = new DefaultHttp2Connection(false);
    conn.addListener(new Http2GoAwayListener(ch));

    final Http2FrameReader reader = new DefaultHttp2FrameReader(validateHeaders);
    final Http2FrameWriter writer = new DefaultHttp2FrameWriter();

    final Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(conn, writer);
    final Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(conn, encoder, reader);

    final Http2Settings http2Settings = http2Settings();

    final Http2ResponseDecoder listener = new Http2ResponseDecoder(conn, ch, encoder);
    final Http2ClientConnectionHandler handler = new Http2ClientConnectionHandler(decoder, encoder,
            http2Settings, listener);//from  w  w w  .  j  av a2 s  .com
    // Setup post build options
    handler.gracefulShutdownTimeoutMillis(clientFactory.idleTimeoutMillis());

    return handler;
}

From source file:com.linecorp.armeria.client.HttpConfigurator.java

License:Apache License

private Http2ConnectionHandler newHttp2ConnectionHandler(Channel ch) {
    final boolean validateHeaders = false;
    final Http2Connection conn = new DefaultHttp2Connection(false);
    conn.addListener(new Http2GoAwayListener(ch));
    final InboundHttp2ToHttpAdapter listener = new InboundHttp2ToHttpAdapterBuilder(conn)
            .propagateSettings(true).validateHttpHeaders(validateHeaders)
            .maxContentLength(options.maxFrameLength()).build();

    Http2FrameReader reader = new DefaultHttp2FrameReader(validateHeaders);
    Http2FrameWriter writer = new DefaultHttp2FrameWriter();

    Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(conn, writer);
    Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(conn, encoder, reader);

    final HttpToHttp2ClientConnectionHandler handler = new HttpToHttp2ClientConnectionHandler(decoder, encoder,
            new Http2Settings(), validateHeaders);

    // Setup post build options
    handler.gracefulShutdownTimeoutMillis(options.idleTimeoutMillis());
    handler.decoder().frameListener(listener);

    return handler;
}

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

License:Apache License

private Http2ConnectionHandler newHttp2ConnectionHandler(ChannelPipeline pipeline) {

    final Http2Connection conn = new DefaultHttp2Connection(true);
    conn.addListener(new Http2GoAwayListener(pipeline.channel()));

    Http2FrameReader reader = new DefaultHttp2FrameReader(true);
    Http2FrameWriter writer = new DefaultHttp2FrameWriter();

    Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(conn, writer);
    Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(conn, encoder, reader);

    final Http2ConnectionHandler handler = new Http2ServerConnectionHandler(decoder, encoder,
            new Http2Settings());

    // Setup post build options
    final Http2RequestDecoder listener = new Http2RequestDecoder(pipeline.channel(), handler.encoder());

    handler.connection().addListener(listener);
    handler.decoder().frameListener(listener);
    handler.gracefulShutdownTimeoutMillis(config.idleTimeoutMillis());

    return handler;
}