Search in sources :

Example 1 with Http2FrameCodecBuilder

use of io.netty.handler.codec.http2.Http2FrameCodecBuilder in project reactor-netty by reactor.

the class HttpServerConfig method configureH2Pipeline.

static void configureH2Pipeline(ChannelPipeline p, boolean accessLogEnabled, @Nullable Function<AccessLogArgProvider, AccessLog> accessLog, @Nullable BiPredicate<HttpServerRequest, HttpServerResponse> compressPredicate, ServerCookieDecoder cookieDecoder, ServerCookieEncoder cookieEncoder, HttpServerFormDecoderProvider formDecoderProvider, @Nullable BiFunction<ConnectionInfo, HttpRequest, ConnectionInfo> forwardedHeaderHandler, Http2Settings http2Settings, ConnectionObserver listener, @Nullable BiFunction<? super Mono<Void>, ? super Connection, ? extends Mono<Void>> mapHandle, int minCompressionSize, ChannelOperations.OnSetup opsFactory, boolean validate) {
    p.remove(NettyPipeline.ReactiveBridge);
    Http2FrameCodecBuilder http2FrameCodecBuilder = Http2FrameCodecBuilder.forServer().validateHeaders(validate).initialSettings(http2Settings);
    if (p.get(NettyPipeline.LoggingHandler) != null) {
        http2FrameCodecBuilder.frameLogger(new Http2FrameLogger(LogLevel.DEBUG, "reactor.netty.http.server.h2"));
    }
    p.addLast(NettyPipeline.HttpCodec, http2FrameCodecBuilder.build()).addLast(NettyPipeline.H2MultiplexHandler, new Http2MultiplexHandler(new H2Codec(accessLogEnabled, accessLog, compressPredicate, cookieDecoder, cookieEncoder, formDecoderProvider, forwardedHeaderHandler, listener, mapHandle, minCompressionSize, opsFactory)));
}
Also used : Http2MultiplexHandler(io.netty.handler.codec.http2.Http2MultiplexHandler) Http2FrameCodecBuilder(io.netty.handler.codec.http2.Http2FrameCodecBuilder) Http2FrameLogger(io.netty.handler.codec.http2.Http2FrameLogger)

Example 2 with Http2FrameCodecBuilder

use of io.netty.handler.codec.http2.Http2FrameCodecBuilder in project reactor-netty by reactor.

the class HttpClientConfig method configureHttp2Pipeline.

static void configureHttp2Pipeline(ChannelPipeline p, boolean acceptGzip, HttpResponseDecoderSpec decoder, Http2Settings http2Settings, ConnectionObserver observer) {
    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"));
    }
    p.addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.HttpCodec, http2FrameCodecBuilder.build()).addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.H2MultiplexHandler, new Http2MultiplexHandler(new H2Codec(acceptGzip))).addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.HttpTrafficHandler, new HttpTrafficHandler(observer));
}
Also used : Http2MultiplexHandler(io.netty.handler.codec.http2.Http2MultiplexHandler) Http2FrameCodecBuilder(io.netty.handler.codec.http2.Http2FrameCodecBuilder) Http2FrameLogger(io.netty.handler.codec.http2.Http2FrameLogger)

Example 3 with Http2FrameCodecBuilder

use of io.netty.handler.codec.http2.Http2FrameCodecBuilder in project reactor-netty by reactor.

the class HttpClientConfig method configureHttp11OrH2CleartextPipeline.

static void configureHttp11OrH2CleartextPipeline(ChannelPipeline p, boolean acceptGzip, HttpResponseDecoderSpec decoder, Http2Settings http2Settings, @Nullable 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, decoder.allowDuplicateContentLengths());
    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, acceptGzip));
    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.addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.HttpDecompressor, new HttpContentDecompressor());
    }
    if (metricsRecorder != null) {
        if (metricsRecorder instanceof HttpClientMetricsRecorder) {
            ChannelHandler handler;
            if (metricsRecorder instanceof MicrometerHttpClientMetricsRecorder) {
                handler = new MicrometerHttpClientMetricsHandler((MicrometerHttpClientMetricsRecorder) metricsRecorder, uriTagValue);
            } else if (metricsRecorder instanceof ContextAwareHttpClientMetricsRecorder) {
                handler = new ContextAwareHttpClientMetricsHandler((ContextAwareHttpClientMetricsRecorder) metricsRecorder, uriTagValue);
            } else {
                handler = new HttpClientMetricsHandler((HttpClientMetricsRecorder) metricsRecorder, uriTagValue);
            }
            p.addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.HttpMetricsHandler, handler);
        }
    }
}
Also used : Http2FrameLogger(io.netty.handler.codec.http2.Http2FrameLogger) Http2ClientUpgradeCodec(io.netty.handler.codec.http2.Http2ClientUpgradeCodec) ChannelHandler(io.netty.channel.ChannelHandler) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) HttpClientUpgradeHandler(io.netty.handler.codec.http.HttpClientUpgradeHandler) Http2FrameCodec(io.netty.handler.codec.http2.Http2FrameCodec) HttpContentDecompressor(io.netty.handler.codec.http.HttpContentDecompressor) Http2FrameCodecBuilder(io.netty.handler.codec.http2.Http2FrameCodecBuilder)

Aggregations

Http2FrameCodecBuilder (io.netty.handler.codec.http2.Http2FrameCodecBuilder)3 Http2FrameLogger (io.netty.handler.codec.http2.Http2FrameLogger)3 Http2MultiplexHandler (io.netty.handler.codec.http2.Http2MultiplexHandler)2 ChannelHandler (io.netty.channel.ChannelHandler)1 HttpClientCodec (io.netty.handler.codec.http.HttpClientCodec)1 HttpClientUpgradeHandler (io.netty.handler.codec.http.HttpClientUpgradeHandler)1 HttpContentDecompressor (io.netty.handler.codec.http.HttpContentDecompressor)1 Http2ClientUpgradeCodec (io.netty.handler.codec.http2.Http2ClientUpgradeCodec)1 Http2FrameCodec (io.netty.handler.codec.http2.Http2FrameCodec)1