@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { boolean lastContent = false; if (msg instanceof Http2HeadersFrame) { final Http2HeadersFrame responseHeaders = (Http2HeadersFrame) msg; final Http2Headers headers = responseHeaders.headers(); lastContent = responseHeaders.isEndStream(); accessLog.status(headers.status()) .chunked(true); } if (msg instanceof Http2DataFrame) { final Http2DataFrame data = (Http2DataFrame) msg; lastContent = data.isEndStream(); accessLog.increaseContentLength(data.content().readableBytes()); } if (lastContent) { ctx.write(msg, promise) .addListener(future -> { if (future.isSuccess()) { accessLog.log(); } }); return; } ctx.write(msg, promise); } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { boolean lastContent = false; if (msg instanceof Http2HeadersFrame) { final Http2HeadersFrame responseHeaders = (Http2HeadersFrame) msg; final Http2Headers headers = responseHeaders.headers(); lastContent = responseHeaders.isEndStream(); accessLog.status(headers.status()) .chunked(true); } if (msg instanceof Http2DataFrame) { final Http2DataFrame data = (Http2DataFrame) msg; lastContent = data.isEndStream(); accessLog.increaseContentLength(data.content().readableBytes()); } if (lastContent) { ctx.write(msg, promise) .addListener(future -> { if (future.isSuccess()) { accessLog.log(); } }); return; } ctx.write(msg, promise); } }
.chunked(chunked); if (!chunked) { accessLog.contentLength(HttpUtil.getContentLength(response, -1));
.chunked(chunked); if (!chunked) { accessLog.contentLength(HttpUtil.getContentLength(response, -1));