use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus in project reactor-netty by reactor.
the class HttpClientWithTomcatTest method contentHeader.
@Test
void contentHeader() {
ConnectionProvider fixed = ConnectionProvider.create("contentHeader", 1);
HttpClient client = HttpClient.create(fixed).wiretap(true).headers(h -> h.add("content-length", "1"));
HttpResponseStatus r = client.request(HttpMethod.GET).uri(getURL()).send(ByteBufFlux.fromString(Mono.just(" "))).responseSingle((res, buf) -> Mono.just(res.status())).block(Duration.ofSeconds(30));
client.request(HttpMethod.GET).uri(getURL()).send(ByteBufFlux.fromString(Mono.just(" "))).responseSingle((res, buf) -> Mono.just(res.status())).block(Duration.ofSeconds(30));
assertThat(r).isEqualTo(HttpResponseStatus.BAD_REQUEST);
fixed.dispose();
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus in project reactor-netty by reactor.
the class AccessLogHandlerH1 method write.
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
if (msg instanceof HttpResponse) {
final HttpResponse response = (HttpResponse) msg;
final HttpResponseStatus status = response.status();
if (status.equals(HttpResponseStatus.CONTINUE)) {
// "FutureReturnValueIgnored" this is deliberate
ctx.write(msg, promise);
return;
}
final boolean chunked = HttpUtil.isTransferEncodingChunked(response);
accessLogArgProvider.response(response).chunked(chunked);
if (!chunked) {
accessLogArgProvider.contentLength(HttpUtil.getContentLength(response, -1));
}
ChannelOperations<?, ?> ops = ChannelOperations.get(ctx.channel());
if (ops instanceof HttpInfos) {
accessLogArgProvider.cookies(((HttpInfos) ops).cookies());
}
}
if (msg instanceof LastHttpContent) {
accessLogArgProvider.increaseContentLength(((LastHttpContent) msg).content().readableBytes());
ctx.write(msg, promise.unvoid()).addListener(future -> {
if (future.isSuccess()) {
AccessLog log = accessLog.apply(accessLogArgProvider);
if (log != null) {
log.log();
}
accessLogArgProvider.clear();
}
});
return;
}
if (msg instanceof ByteBuf) {
accessLogArgProvider.increaseContentLength(((ByteBuf) msg).readableBytes());
}
if (msg instanceof ByteBufHolder) {
accessLogArgProvider.increaseContentLength(((ByteBufHolder) msg).content().readableBytes());
}
// "FutureReturnValueIgnored" this is deliberate
ctx.write(msg, promise);
}
Aggregations