Search in sources :

Example 1 with StreamingInboundHttp2ToHttpAdapter

use of io.micronaut.http.netty.stream.StreamingInboundHttp2ToHttpAdapter in project micronaut-core by micronaut-projects.

the class DefaultHttpClient method newHttp2ConnectionHandlerBuilder.

/**
 * Creates a new {@link HttpToHttp2ConnectionHandlerBuilder} for the given HTTP/2 connection object and config.
 *
 * @param connection    The connection
 * @param configuration The configuration
 * @param stream        Whether this is a stream request
 * @return The {@link HttpToHttp2ConnectionHandlerBuilder}
 */
@NonNull
protected HttpToHttp2ConnectionHandlerBuilder newHttp2ConnectionHandlerBuilder(@NonNull Http2Connection connection, @NonNull HttpClientConfiguration configuration, boolean stream) {
    final HttpToHttp2ConnectionHandlerBuilder builder = new HttpToHttp2ConnectionHandlerBuilder();
    builder.validateHeaders(true);
    final Http2FrameListener http2ToHttpAdapter;
    if (!stream) {
        http2ToHttpAdapter = new InboundHttp2ToHttpAdapterBuilder(connection).maxContentLength(configuration.getMaxContentLength()).validateHttpHeaders(true).propagateSettings(true).build();
    } else {
        http2ToHttpAdapter = new StreamingInboundHttp2ToHttpAdapter(connection, configuration.getMaxContentLength());
    }
    return builder.connection(connection).frameListener(new DelegatingDecompressorFrameListener(connection, http2ToHttpAdapter));
}
Also used : StreamingInboundHttp2ToHttpAdapter(io.micronaut.http.netty.stream.StreamingInboundHttp2ToHttpAdapter) NonNull(io.micronaut.core.annotation.NonNull)

Example 2 with StreamingInboundHttp2ToHttpAdapter

use of io.micronaut.http.netty.stream.StreamingInboundHttp2ToHttpAdapter in project micronaut-core by micronaut-projects.

the class NettyHttpServer method newHttpToHttp2ConnectionHandler.

private HttpToHttp2ConnectionHandler newHttpToHttp2ConnectionHandler() {
    Http2Connection connection = new DefaultHttp2Connection(true);
    final Http2FrameListener http2ToHttpAdapter = new StreamingInboundHttp2ToHttpAdapter(connection, (int) serverConfiguration.getMaxRequestSize(), serverConfiguration.isValidateHeaders(), true);
    final HttpToHttp2ConnectionHandlerBuilder builder = new HttpToHttp2ConnectionHandlerBuilder().frameListener(http2ToHttpAdapter).validateHeaders(serverConfiguration.isValidateHeaders()).initialSettings(serverConfiguration.getHttp2().http2Settings());
    serverConfiguration.getLogLevel().ifPresent(logLevel -> builder.frameLogger(new Http2FrameLogger(logLevel, NettyHttpServer.class)));
    return builder.connection(connection).build();
}
Also used : DefaultHttp2Connection(io.netty.handler.codec.http2.DefaultHttp2Connection) DefaultHttp2Connection(io.netty.handler.codec.http2.DefaultHttp2Connection) Http2Connection(io.netty.handler.codec.http2.Http2Connection) Http2FrameLogger(io.netty.handler.codec.http2.Http2FrameLogger) StreamingInboundHttp2ToHttpAdapter(io.micronaut.http.netty.stream.StreamingInboundHttp2ToHttpAdapter) Http2FrameListener(io.netty.handler.codec.http2.Http2FrameListener) HttpToHttp2ConnectionHandlerBuilder(io.netty.handler.codec.http2.HttpToHttp2ConnectionHandlerBuilder)

Aggregations

StreamingInboundHttp2ToHttpAdapter (io.micronaut.http.netty.stream.StreamingInboundHttp2ToHttpAdapter)2 NonNull (io.micronaut.core.annotation.NonNull)1 DefaultHttp2Connection (io.netty.handler.codec.http2.DefaultHttp2Connection)1 Http2Connection (io.netty.handler.codec.http2.Http2Connection)1 Http2FrameListener (io.netty.handler.codec.http2.Http2FrameListener)1 Http2FrameLogger (io.netty.handler.codec.http2.Http2FrameLogger)1 HttpToHttp2ConnectionHandlerBuilder (io.netty.handler.codec.http2.HttpToHttp2ConnectionHandlerBuilder)1