use of io.netty.handler.codec.http.HttpResponseEncoder in project reactor-netty by reactor.
the class HttpClientTest method abort.
@Test
void abort() {
disposableServer = TcpServer.create().port(0).handle((in, out) -> in.receive().take(1).thenMany(Flux.defer(() -> out.withConnection(c -> c.addHandlerFirst(new HttpResponseEncoder())).sendObject(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.ACCEPTED)).then(Mono.delay(Duration.ofSeconds(2)).then())))).wiretap(true).bindNow();
ConnectionProvider pool = ConnectionProvider.create("abort", 1);
HttpClient client = createHttpClientForContextWithPort(pool);
client.get().uri("/").responseSingle((r, buf) -> Mono.just(r.status().code())).log().block(Duration.ofSeconds(30));
client.get().uri("/").responseContent().log().blockLast(Duration.ofSeconds(30));
client.get().uri("/").responseContent().log().blockLast(Duration.ofSeconds(30));
pool.dispose();
}
use of io.netty.handler.codec.http.HttpResponseEncoder in project apollo by apollo-rsps.
the class HttpChannelInitializer method initChannel.
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("chunker", new HttpObjectAggregator(MAX_REQUEST_LENGTH));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("timeout", new IdleStateHandler(NetworkConstants.IDLE_TIME, 0, 0));
pipeline.addLast("handler", handler);
}
Aggregations