io.netty.handler.codec.http2.Http2ClientUpgradeCodec Java Examples
The following examples show how to use
io.netty.handler.codec.http2.Http2ClientUpgradeCodec.
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: ProtocolNegotiators.java From grpc-java with Apache License 2.0 | 6 votes |
@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { negotiationLogger(ctx).log(ChannelLogLevel.INFO, "Http2Upgrade started"); HttpClientCodec httpClientCodec = new HttpClientCodec(); ctx.pipeline().addBefore(ctx.name(), null, httpClientCodec); Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(next); HttpClientUpgradeHandler upgrader = new HttpClientUpgradeHandler(httpClientCodec, upgradeCodec, /*maxContentLength=*/ 1000); ctx.pipeline().addBefore(ctx.name(), null, upgrader); // Trigger the HTTP/1.1 plaintext upgrade protocol by issuing an HTTP request // which causes the upgrade headers to be added DefaultHttpRequest upgradeTrigger = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"); upgradeTrigger.headers().add(HttpHeaderNames.HOST, authority); ctx.writeAndFlush(upgradeTrigger).addListener( ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); super.handlerAdded(ctx); }
Example #2
Source File: ProtocolNegotiators.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Override public Handler newHandler(GrpcHttp2ConnectionHandler handler) { // Register the plaintext upgrader Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(handler); HttpClientCodec httpClientCodec = new HttpClientCodec(); final HttpClientUpgradeHandler upgrader = new HttpClientUpgradeHandler(httpClientCodec, upgradeCodec, 1000); return new BufferingHttp2UpgradeHandler(upgrader, handler); }
Example #3
Source File: Http2ClientInitializer.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
/** * Configure the pipeline for a cleartext upgrade from HTTP to HTTP/2. */ private void configureClearText(SocketChannel ch) { HttpClientCodec sourceCodec = new HttpClientCodec(); Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(connectionHandler); HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, 65536); ch.pipeline().addLast(sourceCodec, upgradeHandler, new UpgradeRequestHandler(), new UserEventLogger()); }
Example #4
Source File: Http2ClientInitializer.java From product-microgateway with Apache License 2.0 | 5 votes |
/** * Configure the pipeline for a cleartext upgrade from HTTP to HTTP/2. */ private void configureClearText(SocketChannel ch) { HttpClientCodec sourceCodec = new HttpClientCodec(); Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(connectionHandler); HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, 65536); ch.pipeline().addLast(sourceCodec, upgradeHandler, new UpgradeRequestHandler(), new UserEventLogger()); }
Example #5
Source File: Http2ClientInitializer.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * Configure the pipeline for a cleartext upgrade from HTTP to HTTP/2. */ private void configureClearTextWithHttpUpgrade(SocketChannel ch) { HttpClientCodec sourceCodec = new HttpClientCodec(); Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(connectionHandler); HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, 65536); ch.pipeline().addLast(sourceCodec, upgradeHandler, new UpgradeRequestHandler(), new UserEventLogger()); }
Example #6
Source File: Http2ClientInitializer.java From jmeter-http2-plugin with Apache License 2.0 | 5 votes |
/** * Configure the pipeline for a cleartext upgrade from HTTP to HTTP/2. */ private void configureClearText(SocketChannel ch) { HttpClientCodec sourceCodec = new HttpClientCodec(); Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(connectionHandler); HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, 65536); ch.pipeline().addLast("Http2SourceCodec", sourceCodec); ch.pipeline().addLast("Http2UpgradeHandler", upgradeHandler); ch.pipeline().addLast("Http2UpgradeRequestHandler", new UpgradeRequestHandler()); ch.pipeline().addLast("Logger", new UserEventLogger()); }
Example #7
Source File: THttp2Client.java From armeria with Apache License 2.0 | 5 votes |
@Override public void initChannel(SocketChannel ch) throws Exception { final ChannelPipeline p = ch.pipeline(); final Http2Connection conn = new DefaultHttp2Connection(false); final HttpToHttp2ConnectionHandler connHandler = new HttpToHttp2ConnectionHandlerBuilder() .connection(conn) .frameListener(new DelegatingDecompressorFrameListener( conn, new InboundHttp2ToHttpAdapterBuilder(conn) .maxContentLength(Integer.MAX_VALUE) .propagateSettings(true).build())) .build(); clientHandler = new THttp2ClientHandler(ch.eventLoop()); if (sslCtx != null) { p.addLast(sslCtx.newHandler(p.channel().alloc())); p.addLast(connHandler); configureEndOfPipeline(p); } else { final HttpClientCodec sourceCodec = new HttpClientCodec(); final HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler( sourceCodec, new Http2ClientUpgradeCodec(connHandler), 65536); p.addLast(sourceCodec, upgradeHandler, new UpgradeRequestHandler()); } }
Example #8
Source File: Http2ClientInitializer.java From netty-cookbook with Apache License 2.0 | 5 votes |
/** * Configure the pipeline for a cleartext upgrade from HTTP to HTTP/2. */ private void configureClearText(SocketChannel ch) { HttpClientCodec sourceCodec = new HttpClientCodec(); Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(connectionHandler); HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, 65536); ch.pipeline().addLast("Http2SourceCodec", sourceCodec); ch.pipeline().addLast("Http2UpgradeHandler", upgradeHandler); ch.pipeline().addLast("Http2UpgradeRequestHandler", new UpgradeRequestHandler()); ch.pipeline().addLast("Logger", new UserEventLogger()); }
Example #9
Source File: HttpClientConfig.java From reactor-netty with Apache License 2.0 | 4 votes |
static void configureHttp11OrH2CleartextPipeline( ChannelPipeline p, boolean acceptGzip, HttpResponseDecoderSpec decoder, Http2Settings http2Settings, @Nullable Supplier<? extends ChannelMetricsRecorder> metricsRecorder, ConnectionObserver observer, ChannelOperations.OnSetup opsFactory, @Nullable Function<String, String> uriTagValue) { HttpClientCodec httpClientCodec = new HttpClientCodec( decoder.maxInitialLineLength(), decoder.maxHeaderSize(), decoder.maxChunkSize(), decoder.failOnMissingResponse, decoder.validateHeaders(), decoder.initialBufferSize(), decoder.parseHttpAfterConnectRequest); Http2FrameCodecBuilder http2FrameCodecBuilder = Http2FrameCodecBuilder.forClient() .validateHeaders(decoder.validateHeaders()) .initialSettings(http2Settings); if (p.get(NettyPipeline.LoggingHandler) != null) { http2FrameCodecBuilder.frameLogger(new Http2FrameLogger(LogLevel.DEBUG, "reactor.netty.http.client.h2")); } Http2FrameCodec http2FrameCodec = http2FrameCodecBuilder.build(); Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(http2FrameCodec, new H2CleartextCodec(http2FrameCodec, opsFactory)); HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(httpClientCodec, upgradeCodec, decoder.h2cMaxContentLength()); p.addBefore(NettyPipeline.ReactiveBridge, null, httpClientCodec) .addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.H2CUpgradeHandler, upgradeHandler) .addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.HttpTrafficHandler, new HttpTrafficHandler(observer)); if (acceptGzip) { p.addAfter(NettyPipeline.HttpCodec, NettyPipeline.HttpDecompressor, new HttpContentDecompressor()); } if (metricsRecorder != null) { ChannelMetricsRecorder channelMetricsRecorder = metricsRecorder.get(); if (channelMetricsRecorder instanceof HttpClientMetricsRecorder) { p.addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.HttpMetricsHandler, new HttpClientMetricsHandler((HttpClientMetricsRecorder) channelMetricsRecorder, uriTagValue)); } } }