Search in sources :

Example 1 with CopyByteBufHandlerChannelInitializer

use of io.servicetalk.transport.netty.internal.CopyByteBufHandlerChannelInitializer in project servicetalk by apple.

the class NettyHttpServer method getChannelInitializer.

private static ChannelInitializer getChannelInitializer(final ByteBufAllocator alloc, final H1ProtocolConfig config, final CloseHandler closeHandler) {
    // user-code. Therefore, ByteBufs must be copied to unpooled memory before HttpObjectDecoder.
    return new CopyByteBufHandlerChannelInitializer(alloc).andThen(channel -> {
        Queue<HttpRequestMethod> methodQueue = new ArrayDeque<>(2);
        final ChannelPipeline pipeline = channel.pipeline();
        final HttpRequestDecoder decoder = new HttpRequestDecoder(methodQueue, alloc, config.headersFactory(), config.maxStartLineLength(), config.maxHeaderFieldLength(), config.specExceptions().allowPrematureClosureBeforePayloadBody(), config.specExceptions().allowLFWithoutCR(), closeHandler);
        pipeline.addLast(decoder);
        pipeline.addLast(new HttpResponseEncoder(methodQueue, config.headersEncodedSizeEstimate(), config.trailersEncodedSizeEstimate(), closeHandler, decoder));
    });
}
Also used : HttpRequestMethod(io.servicetalk.http.api.HttpRequestMethod) CopyByteBufHandlerChannelInitializer(io.servicetalk.transport.netty.internal.CopyByteBufHandlerChannelInitializer) ArrayDeque(java.util.ArrayDeque) ChannelPipeline(io.netty.channel.ChannelPipeline)

Aggregations

ChannelPipeline (io.netty.channel.ChannelPipeline)1 HttpRequestMethod (io.servicetalk.http.api.HttpRequestMethod)1 CopyByteBufHandlerChannelInitializer (io.servicetalk.transport.netty.internal.CopyByteBufHandlerChannelInitializer)1 ArrayDeque (java.util.ArrayDeque)1