io.netty.handler.codec.http2.Http2ConnectionHandler Java Examples

The following examples show how to use io.netty.handler.codec.http2.Http2ConnectionHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NoPriorityByteDistributionBenchmark.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Setup(Level.Trial)
public void setupTrial() throws Exception {
    connection = new DefaultHttp2Connection(false);
    dataRefresherKey = connection.newKey();

    // Create the flow controller
    switch (algorithm) {
        case WFQ:
            distributor = new WeightedFairQueueByteDistributor(connection, 0);
            break;
        case UNIFORM:
            distributor = new UniformStreamByteDistributor(connection);
            break;
    }
    controller = new DefaultHttp2RemoteFlowController(connection, new ByteCounter(distributor));
    connection.remote().flowController(controller);
    Http2ConnectionHandler handler = new Http2ConnectionHandlerBuilder()
        .encoderEnforceMaxConcurrentStreams(false).validateHeaders(false)
        .frameListener(new Http2FrameAdapter())
        .connection(connection)
        .build();
    ctx = new EmbeddedChannelWriteReleaseHandlerContext(PooledByteBufAllocator.DEFAULT, handler) {
        @Override
        protected void handleException(Throwable t) {
            handleUnexpectedException(t);
        }
    };
    handler.handlerAdded(ctx);
    handler.channelActive(ctx);

    // Create the streams, each initialized with MAX_INT bytes.
    for (int i = 0; i < numStreams; ++i) {
        Http2Stream stream = connection.local().createStream(toStreamId(i), false);
        addData(stream, Integer.MAX_VALUE);
        stream.setProperty(dataRefresherKey, new DataRefresher(stream));
    }
}
 
Example #2
Source File: Http2HandlerBuilder.java    From xrpc with Apache License 2.0 5 votes vote down vote up
@Override
protected Http2ConnectionHandler build(
    Http2ConnectionDecoder decoder,
    Http2ConnectionEncoder encoder,
    Http2Settings initialSettings) {

  // TODO(jkinkead): Set MAX_CONCURRENT_STREAMS value to something from config.
  decoder.frameListener(new Http2Handler(encoder, maxPayloadBytes, corsHandler));

  return new ConnectionHandler(decoder, encoder, initialSettings);
}
 
Example #3
Source File: ReactorNetty.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
static boolean mustChunkFileTransfer(Connection c, Path file) {
	// if channel multiplexing a parent channel as an http2 stream
	if (c.channel().parent() != null && c.channel().parent().pipeline().get(Http2ConnectionHandler.class) != null) {
		return true;
	}
	ChannelPipeline p = c.channel().pipeline();
	return p.get(SslHandler.class) != null  ||
			p.get(NettyPipeline.CompressionHandler) != null ||
			(!(c.channel().eventLoop() instanceof NioEventLoop) &&
					!"file".equals(file.toUri().getScheme()));
}
 
Example #4
Source File: HttpServerPipelineConfigurator.java    From armeria with Apache License 2.0 5 votes vote down vote up
private Http2ConnectionHandler newHttp2ConnectionHandler(ChannelPipeline pipeline, AsciiString scheme) {
    final Timer keepAliveTimer = newKeepAliveTimer(scheme == SCHEME_HTTP ? H2C : H2);
    return new Http2ServerConnectionHandlerBuilder(pipeline.channel(), config, keepAliveTimer,
                                                   gracefulShutdownSupport, scheme.toString())
            .server(true)
            .initialSettings(http2Settings())
            .build();
}
 
Example #5
Source File: Http2HandlerBuilder.java    From xrpc with Apache License 2.0 4 votes vote down vote up
@Override
public Http2ConnectionHandler build() {
  return super.build();
}
 
Example #6
Source File: Http2OrHttpHandler.java    From netty-cookbook with Apache License 2.0 4 votes vote down vote up
@Override
protected Http2ConnectionHandler createHttp2RequestHandler() {
    return new HelloWorldHttp2Handler();
}