use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpServerCodec in project reactor-netty by reactor.
the class HttpServerTests method httpServerRequestConfigInjectAttributes.
@Test
void httpServerRequestConfigInjectAttributes() {
AtomicReference<Channel> channelRef = new AtomicReference<>();
AtomicBoolean validate = new AtomicBoolean();
AtomicInteger chunkSize = new AtomicInteger();
AtomicBoolean allowDuplicateContentLengths = new AtomicBoolean();
disposableServer = createServer().httpRequestDecoder(opt -> opt.maxInitialLineLength(123).maxHeaderSize(456).maxChunkSize(789).validateHeaders(false).initialBufferSize(10).allowDuplicateContentLengths(true)).handle((req, resp) -> req.receive().then(resp.sendNotFound())).doOnConnection(c -> {
channelRef.set(c.channel());
HttpServerCodec codec = c.channel().pipeline().get(HttpServerCodec.class);
HttpObjectDecoder decoder = (HttpObjectDecoder) getValueReflection(codec, "inboundHandler", 1);
chunkSize.set((Integer) getValueReflection(decoder, "maxChunkSize", 2));
validate.set((Boolean) getValueReflection(decoder, "validateHeaders", 2));
allowDuplicateContentLengths.set((Boolean) getValueReflection(decoder, "allowDuplicateContentLengths", 2));
}).bindNow();
createClient(disposableServer::address).post().uri("/").send(ByteBufFlux.fromString(Mono.just("bodysample"))).responseContent().aggregate().asString().block();
assertThat(channelRef.get()).isNotNull();
assertThat(chunkSize).as("line length").hasValue(789);
assertThat(validate).as("validate headers").isFalse();
assertThat(allowDuplicateContentLengths).as("allow duplicate Content-Length").isTrue();
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpServerCodec in project reactor-netty by reactor.
the class ConnectionTest method addNonByteDecoderWhenFullReactorPipeline.
@Test
void addNonByteDecoderWhenFullReactorPipeline() {
channel.pipeline().addLast(NettyPipeline.HttpCodec, new HttpServerCodec()).addLast(NettyPipeline.HttpTrafficHandler, httpTrafficHandlerMock).addLast(NettyPipeline.ReactiveBridge, reactiveBridgeMock);
testContext.addHandlerLast(DECODER_NAME, decoder);
assertThat(channel.pipeline().names()).containsExactly(NettyPipeline.HttpCodec, NettyPipeline.HttpTrafficHandler, DECODER_NAME, NettyPipeline.ReactiveBridge, TAIL_CONTEXT_NAME);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpServerCodec in project reactor-netty by reactor.
the class ConnectionTest method addByteDecoderWhenFullReactorPipeline.
@Test
void addByteDecoderWhenFullReactorPipeline() {
channel.pipeline().addLast(NettyPipeline.HttpCodec, new HttpServerCodec()).addLast(NettyPipeline.HttpTrafficHandler, httpTrafficHandlerMock).addLast(NettyPipeline.ReactiveBridge, reactiveBridgeMock);
testContext.addHandlerLast(DECODER_NAME, decoder).addHandlerFirst(DECODER_EXTRACT_NAME, NettyPipeline.inboundHandler(ADD_EXTRACTOR));
assertThat(channel.pipeline().names()).containsExactly(NettyPipeline.HttpCodec, NettyPipeline.HttpTrafficHandler, DECODER_EXTRACT_NAME, DECODER_NAME, NettyPipeline.ReactiveBridge, TAIL_CONTEXT_NAME);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpServerCodec in project reactor-netty by reactor.
the class ConnectionTest method addSeveralByteDecodersWhenCodec.
@Test
void addSeveralByteDecodersWhenCodec() {
ChannelHandler decoder1 = new LineBasedFrameDecoder(12);
ChannelHandler decoder2 = new LineBasedFrameDecoder(13);
channel.pipeline().addLast(NettyPipeline.HttpCodec, new HttpServerCodec()).addLast(NettyPipeline.HttpTrafficHandler, httpTrafficHandlerMock).addLast(NettyPipeline.ReactiveBridge, reactiveBridgeMock);
testContext.addHandlerLast("decoder1$extract", NettyPipeline.inboundHandler(ADD_EXTRACTOR)).addHandlerLast("decoder1", decoder1).addHandlerLast("decoder2$extract", NettyPipeline.inboundHandler(ADD_EXTRACTOR)).addHandlerLast("decoder2", decoder2);
assertThat(channel.pipeline().names()).containsExactly(NettyPipeline.HttpCodec, NettyPipeline.HttpTrafficHandler, "decoder1$extract", "decoder1", "decoder2$extract", "decoder2", NettyPipeline.ReactiveBridge, TAIL_CONTEXT_NAME);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpServerCodec in project reactor-netty by reactor.
the class ConnectionTest method addNonByteEncoderWhenNoRight.
@Test
void addNonByteEncoderWhenNoRight() {
channel.pipeline().addLast(NettyPipeline.HttpCodec, new HttpServerCodec());
testContext.addHandlerFirst(ENCODER_NAME, encoder);
assertThat(channel.pipeline().names()).containsExactly(NettyPipeline.HttpCodec, ENCODER_NAME, TAIL_CONTEXT_NAME);
}
Aggregations