Search in sources :

Example 6 with HttpRequestMethod

use of io.servicetalk.http.api.HttpRequestMethod 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

HttpRequestMethod (io.servicetalk.http.api.HttpRequestMethod)6 HttpResponseStatus (io.servicetalk.http.api.HttpResponseStatus)2 ChannelPipeline (io.netty.channel.ChannelPipeline)1 Http2DataFrame (io.netty.handler.codec.http2.Http2DataFrame)1 Http2Headers (io.netty.handler.codec.http2.Http2Headers)1 Http2HeadersFrame (io.netty.handler.codec.http2.Http2HeadersFrame)1 HttpHeaders (io.servicetalk.http.api.HttpHeaders)1 CopyByteBufHandlerChannelInitializer (io.servicetalk.transport.netty.internal.CopyByteBufHandlerChannelInitializer)1 ArrayDeque (java.util.ArrayDeque)1